From 627b7f9278c4d09d31c9c9f53631fa02569c8a6a Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Wed, 20 Dec 2017 17:36:25 -0700 Subject: [PATCH] Add "listapps" API --- api.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/api.php b/api.php index 5fc55c8..6e36466 100644 --- a/api.php +++ b/api.php @@ -296,6 +296,15 @@ switch ($VARS['action']) { } else { exit(json_encode(["status" => "ERROR", "msg" => lang("no such code or code expired", false)])); } + case "listapps": + $apps = EXTERNAL_APPS; + // Format paths as absolute URLs + foreach ($apps as $k => $v) { + if (strpos($apps[$k]['url'], "http") === FALSE) { + $apps[$k]['url'] = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://" . $_SERVER['HTTP_HOST'] . ($_SERVER['SERVER_PORT'] != 80 || $_SERVER['SERVER_PORT'] != 443 ? ":" . $_SERVER['SERVER_PORT'] : "") . $apps[$k]['url']; + } + } + exit(json_encode(["status" => "OK", "apps" => $apps])); default: http_response_code(404); die(json_encode("404 Not Found: the requested action is not available."));