diff options
author | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-03-26 17:11:33 +0000 |
---|---|---|
committer | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-03-26 17:11:33 +0000 |
commit | 8f19a7382a1c808eb696f8fd62b06196b6c56fa1 (patch) | |
tree | b83007b562da804b6356d254a6808222ab3d5484 /mod/apitest/index.php | |
parent | fafa17160223deaab78da1203657bbeb1b218ad7 (diff) | |
download | elgg-8f19a7382a1c808eb696f8fd62b06196b6c56fa1.tar.gz elgg-8f19a7382a1c808eb696f8fd62b06196b6c56fa1.tar.bz2 |
Marcus Povey <marcus@dushka.co.uk>
* Basic API testrig
git-svn-id: https://code.elgg.org/elgg/trunk@270 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/apitest/index.php')
-rw-r--r-- | mod/apitest/index.php | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/mod/apitest/index.php b/mod/apitest/index.php new file mode 100644 index 000000000..16a7794df --- /dev/null +++ b/mod/apitest/index.php @@ -0,0 +1,68 @@ +<?php + require_once("../../engine/start.php"); + + global $CONFIG, $API_CLIENT; + + + // Get some variables + $apikey = get_input("apikey"); + $secret = get_input("secret"); + $endpoint = get_input("endpoint"); + + + if ($_REQUEST['action'] == "configure") + apitest_configure($apikey, $secret, $endpoint); + + // Get a list of commands + if ($API_CLIENT->configured == true) + { + $commands = apitest_call( + array ( + 'method' => 'system.api.list' + ) + ); + $commands = $commands->result; + } + + /* See if we are executing a method - This is a quick demo, obviously use functions as they are much easier!*/ + if (isset($_REQUEST['method'])) + { + + $command_details = $commands[$_REQUEST['method']]; + $auth_req = $command_details['require_auth'] == 1 ? true : false; + + $params = array(); + $params['method'] = $_REQUEST['method']; + if ($auth_req) + $params['auth_token'] = $_REQUEST['auth_token']; + + foreach ($command_details['parameters'] as $k => $v) + { + $params[$k] = $_REQUEST[$k]; + } + + $result = apitest_call($params, $_REQUEST['post_data']); + + + if ($result->status == 0) + system_message("<div id=\"result\"><pre>".print_r($result->result, true)."</pre></div>"); + else + register_error($result->message); + + if (!is_object($result)) echo $LAST_CALL_RAW; + + + + } + + // Draw command form + $list = ""; + foreach ($commands as $command => $details) + $list .= apitest_draw_command_form($command, $details); + + $body = elgg_view("apitest/main", array( + "config" => apitest_draw_config_panel(), + "commandlist" => $list + )); + page_draw("API Commands",$body); +?>
\ No newline at end of file |