]> git.mxchange.org Git - friendica.git/blob - src/Module/WellKnown/NodeInfo.php
Merge pull request #8019 from nupplaphil/task/replace_getClass
[friendica.git] / src / Module / WellKnown / NodeInfo.php
1 <?php
2
3 namespace Friendica\Module\WellKnown;
4
5 use Friendica\BaseModule;
6 use Friendica\DI;
7
8 /**
9  * Standardized way of exposing metadata about a server running one of the distributed social networks.
10  * @see https://github.com/jhass/nodeinfo/blob/master/PROTOCOL.md
11  */
12 class NodeInfo extends BaseModule
13 {
14         public static function rawContent(array $parameters = [])
15         {
16                 self::printWellKnown();
17         }
18
19         /**
20          * Prints the well-known nodeinfo redirect
21          *
22          * @throws \Friendica\Network\HTTPException\NotFoundException
23          */
24         private static function printWellKnown()
25         {
26                 $nodeinfo = [
27                         'links' => [
28                                 ['rel'  => 'http://nodeinfo.diaspora.software/ns/schema/1.0',
29                                 'href' => DI::baseUrl()->get() . '/nodeinfo/1.0'],
30                                 ['rel'  => 'http://nodeinfo.diaspora.software/ns/schema/2.0',
31                                 'href' => DI::baseUrl()->get() . '/nodeinfo/2.0'],
32                         ]
33                 ];
34
35                 header('Content-type: application/json; charset=utf-8');
36                 echo json_encode($nodeinfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
37                 exit;
38         }
39 }