require_once("mod/hostxrd.php");\r
\r
function _well_known_init(&$a){\r
- if ($a->argc > 1) {\r
- switch($a->argv[1]) {\r
- case "host-meta":\r
- hostxrd_init($a);\r
- break;\r
- }\r
- }\r
- http_status_exit(404);\r
- killme();\r
+ if ($a->argc > 1) {\r
+ switch($a->argv[1]) {\r
+ case "host-meta":\r
+ hostxrd_init($a);\r
+ break;\r
+ case "x-social-relay":\r
+ wk_social_relay($a);\r
+ break;\r
+ }\r
+ }\r
+ http_status_exit(404);\r
+ killme();\r
+}\r
+\r
+function wk_social_relay(&$a) {\r
+\r
+ define('SR_SCOPE_ALL', 'all');\r
+ define('SR_SCOPE_TAGS', 'tags');\r
+\r
+ $subscribe = (bool)true;\r
+ $scope = SR_SCOPE_ALL;\r
+ //$scope = SR_SCOPE_TAGS;\r
+\r
+ $tags = array();\r
+\r
+ if ($scope == SR_SCOPE_TAGS) {\r
+ $terms = q("SELECT DISTINCT(`term`) FROM `search`");\r
+\r
+ foreach($terms AS $term) {\r
+ $tag = trim($term["term"], "#");\r
+ $tags[] = $tag;\r
+ }\r
+ }\r
+\r
+ $relay = array("subscribe" => $subscribe,\r
+ "scope" => $scope,\r
+ "tags" => array_unique($tags));\r
+\r
+ header('Content-type: application/json; charset=utf-8');\r
+ echo json_encode($relay, true);\r
+ exit;\r
}\r