]> git.mxchange.org Git - friendica.git/blob - src/Module/WellKnown/NodeInfo.php
Introduce new DI container
[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 use Friendica\DI;
8
9 /**
10  * Standardized way of exposing metadata about a server running one of the distributed social networks.
11  * @see https://github.com/jhass/nodeinfo/blob/master/PROTOCOL.md
12  */
13 class NodeInfo extends BaseModule
14 {
15         public static function rawContent(array $parameters = [])
16         {
17                 $app = DI::app();
18
19                 self::printWellKnown($app);
20         }
21
22         /**
23          * Prints the well-known nodeinfo redirect
24          *
25          * @param App $app
26          *
27          * @throws \Friendica\Network\HTTPException\NotFoundException
28          */
29         private static function printWellKnown(App $app)
30         {
31                 $nodeinfo = [
32                         'links' => [
33                                 ['rel'  => 'http://nodeinfo.diaspora.software/ns/schema/1.0',
34                                 'href' => $app->getBaseURL() . '/nodeinfo/1.0'],
35                                 ['rel'  => 'http://nodeinfo.diaspora.software/ns/schema/2.0',
36                                 'href' => $app->getBaseURL() . '/nodeinfo/2.0'],
37                         ]
38                 ];
39
40                 header('Content-type: application/json; charset=utf-8');
41                 echo json_encode($nodeinfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
42                 exit;
43         }
44 }