Tfe

Ongi etorri tfe-ren webgunera...

Blog/activity_pub_php/1_well_known.php

(Deskargatu)
<?php

$resource = $_GET["resource"];
$user = preg_replace("/acct:([^@]+).*/","$1", $resource);
if(!preg_match("/^acct:(gurekontua)@".$_SERVER["HTTP_HOST"]."$/", $resource))
{
    throw  'Invalid user';
}

$data = [
    'subject' => $resource,
    'aliases' => [
        "https://".$_SERVER["HTTP_HOST"]."/activityPub/users/$user",
    ],
    'links' => [
        [
            "rel" => "http://webfinger.net/rel/profile-page",
            "type" => "text/html",
            "href" => "https://".$_SERVER["HTTP_HOST"]."/",
        ],
        [
            'rel' => 'self',
            'type' => 'application/activity+json',
            'href' => "https://".$_SERVER["HTTP_HOST"]."/activityPub/users/$user",
        ],
        [
            'rel' => 'http://webfinger.net/rel/avatar',
            'type' => 'image/png',
            'href' => "https://".$_SERVER["HTTP_HOST"]."/images/logo.png",
        ]
    ]
];
header('Content-Type: application/jrd+json; charset=utf-8');
echo json_encode($response);