Recent site activity

API‎ > ‎

3 - Structure

Request fields

Requests comprise HTTP URLs with parameters passed either in the query string, in the usual way, or as form data. The two can be mixed and matched to suit the application but all functions described here can be operated by the creation of simple HTML pages or manually created links.

The call to the API will contain the following field plus any additional fields required by the command itself. Optional values not relevant to any specific commands are detailed here as well.

 token Issued in response to a valid AUTH request and destroyed by a valid DEAUTH request. REQUIRED
 mode The command required, e.g. BALA REQUIRED
 output Controls the format of the response. Valid values are xml, json, serial, text and php. xml is assumed if no value it specified. Examples of each are given below. 

An example (non-working) would thus be:
http://ws.simwood.com/REST.php?mode=BALA&token=6dac259d704ae993ec7d6fbc0d08c70e66b46288

Response fields

The response will always consist of the following three fields:

 status A numeric value indicating the success of the request. 1 means success, anything else indicates an error. A description of any error will be given in the Message field.
 message OK if all has gone well, otherwise an error/informational message.
 results This is a container for the results of the request. It will be empty if the Status does not equal 1 but otherwise will contain a set, or multiple sets of the fields detailed in the Command Reference.

Example output

According to the ‘output’ field in the request, if any, results will come in one of four formats. An example of each for the BALA command is show below:

XML
<?xml version="1.0" encoding="utf-8"?>
<data>
<status>1</status>
<message>OK</message>
<results>
<account>939998</account>
<balance>10928.000</balance>
<currency>GBP</currency>
</results>
</data>

JSON
{"status":"1","message":"OK","results":{"account":"939998","balance":"10928.000","currency":"GBP"}}

Serial
a:3:{s:6:"status";s:1:"1";s:7:"message";s:2:"OK";s:7:"results";a:3:{s:7:"account";s:6:"939998";s:7:"balance";s:8:"10928.000";s:8:"currency";s:3:"GBP";}}

Text
[data]
status=1
message=OK
[results]
account=939998
balance=10928.000
currency=GBP

PHP
Array
(
    [status] => 1
    [message] => OK
    [results] => Array
    (
         [account] => 939998
         [balance] => 10928.000
         [currency] => GBP
    )
)

We would recommend XML format for general use. It is well formed and can easily be passed through an XSLT to yield almost any custom format you require.

The text format has limitations which may in the long-run make it more complicated than other formats, e.g. the nesting of values isn’t possible, but is simpler to read. The php format is easily readable by those familiar with PHP whilst serial outputs a serialised PHP array which can be accessed in a single command. JSON has the benefits of XML with single-command de-serialisation from most languages.

It should be noted however that as the output format is specified on a per request basis, you may choose to use different formats for different commands according to your intended use for the results.