aboutsummaryrefslogtreecommitdiff
path: root/lib/activitypub-webfinger.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/activitypub-webfinger.php')
-rw-r--r--lib/activitypub-webfinger.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/activitypub-webfinger.php b/lib/activitypub-webfinger.php
new file mode 100644
index 0000000..2ad44fb
--- /dev/null
+++ b/lib/activitypub-webfinger.php
@@ -0,0 +1,22 @@
+<?php
+
+ // todo: handle empty usernames
+
+ $actor = ltrim($config['microblog_account'], '@');
+ $url = parse_url($config['url']);
+ $domain = $url['host'];
+ if(!empty($url['path'])) $domain .= rtrim($url['path'], '/');
+
+ $data = [
+ 'subject' => 'acct:'.$actor.'@'.$domain,
+ 'links' => [
+ [
+ 'rel' => 'self',
+ 'type' => 'application/activity+json',
+ 'href' => $config['url'].'/actor'
+ ]
+ ]
+ ];
+
+ header('Content-Type: application/ld+json');
+ echo(json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));