]> git.mxchange.org Git - friendica.git/blob - src/Module/WellKnown/NodeInfo.php
Modules separated
[friendica.git] / src / Module / WellKnown / NodeInfo.php
1 <?php
2
3 namespace Friendica\Module\WellKnown;
4
5 use Friendica\App;
6 use Friendica\BaseModule;
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                 $app = self::getApp();
17
18                 self::printWellKnown($app);
19         }
20
21         /**
22          * Prints the well-known nodeinfo redirect
23          *
24          * @param App $app
25          *
26          * @throws \Friendica\Network\HTTPException\NotFoundException
27          */
28         private static function printWellKnown(App $app)
29         {
30                 $nodeinfo = [
31                         'links' => [
32                                 ['rel'  => 'http://nodeinfo.diaspora.software/ns/schema/1.0',
33                                 'href' => $app->getBaseURL() . '/nodeinfo/1.0'],
34                                 ['rel'  => 'http://nodeinfo.diaspora.software/ns/schema/2.0',
35                                 'href' => $app->getBaseURL() . '/nodeinfo/2.0'],
36                         ]
37                 ];
38
39                 header('Content-type: application/json; charset=utf-8');
40                 echo json_encode($nodeinfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
41                 exit;
42         }
43 }