Skip to content
lachko edited this page Jul 24, 2012 · 2 revisions

The API

All API methods are exposed through the apis_controller. The API itself serves REST requests. Note that, for now, all requests should be GET. This is because we never submit a form per se. Rather do a GET with some parameters set in the URL and receive the result in an XML file.

Accessing the API

All methods can be hit on APP_URL/apis/METHOD/PARAM_1/PARAM_2/PARAM_N.xml The following headers must be sent to the API: "Authorization": "TRUEREST username=admin&password=admin12&apikey=247b5a2f72df37527" "Content-Type": "text/xml" Though we aren't currently using the api key parameter it must be provided. Also note that a username/ password pair must be supplied. This user will be used to perform the operation on behalf of the phone number sending the message. In the near future this will be changed so that the operation is restricted based on the phone's assigned user rights.

A sample request is: http://localhost/track/apis/receiveUnit/377355511111/1253/CSRo.xml. Note that the order of parameters is important and must be correct

The reply that the server will send back to the above request is: <?xml version="1.0" encoding="utf-8"?> <apis_response> <data/> <meta> <status>ok</status> <feedback> <item> <message>Unit does not exist: 1253</message> <level>error</level> </item> </feedback> <request> <http_host>localhost:10080</http_host> <http_user_agent>Mozilla/5.0 (Windows NT 6.0; rv:12.0) Gecko/20100101 Firefox/12.0</http_user_agent> <server_addr>::1</server_addr> <remote_addr>::1</remote_addr> <server_protocol>HTTP/1.1</server_protocol> <request_method>GET</request_method> <request_uri>/track/apis/receiveUnit/3773234003/1253/CSRo.xml</request_uri> <request_time>1337004054</request_time> </request> <credentials> <class>Customer</class> <apikey>247b5a2f72df375279573f2746686daa</apikey> <username>admin</username> </credentials> <time_epoch>1337004056</time_epoch> <time_local>Mon, 14 May 2012 16:00:56 +0200</time_local> <version>0.3</version> </meta> </apis_response> The feedback/item/level should be checked for the status of the request. It can be error or info. And the message field contains the reply. The above request was not successful. The feedback container will look like this if it were a successful message: <feedback> <item> <message>Thank you. Your report was successfully submitted.</message> <level>info</level> </item> </feedback>

Available methods

Clone this wiki locally