aboutsummaryrefslogtreecommitdiff
path: root/lib/activitypub-webfinger.php
diff options
context:
space:
mode:
authorArno Richter <oelna@oelna.de>2023-01-13 17:47:09 +0100
committerArno Richter <oelna@oelna.de>2023-01-13 17:47:09 +0100
commitff2858b6ea8f586daa95e51ae21315f86cc5ded5 (patch)
tree4e5ce30ad1d7e1de8404900c9cec9d9bf01dbf6d /lib/activitypub-webfinger.php
parent3ebd3dcfe6b564ddfe5dcbc0ff9f2bb1fa92c761 (diff)
downloadmicroblog-ff2858b6ea8f586daa95e51ae21315f86cc5ded5.tar.gz
microblog-ff2858b6ea8f586daa95e51ae21315f86cc5ded5.tar.bz2
microblog-ff2858b6ea8f586daa95e51ae21315f86cc5ded5.zip
first draft of activitypub support
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));