API for remote booking
Striving to support easier and friendlier service Share Timetable support remote access to Timetables services.
Share Timetable API allow making query and booking remotely. See example using our WordPress plugin.
The basic design of this API is a server to server communication based on HTTP messages with return value formed as XML file.
API methods
Test
GET: http://app.sharetimetable.com/api/test/PUBLIC_ID
This method allow you to test that the Timetable is present and that the API is active.
Parameter
- PUBLIC_ID – Timetable’s Public ID
Return
<!-- Share Timetable API -->
<data>
<version>1.0</version>
<name>Timetable Name</name>
<info>Timetable Information</info>
<active>1</active> // API is active for this Timetable.
</data>
Code Example (php)
$url = "http://app.sharetimetable.com/api/test/".$this->o["public_id_str"];
$dh = fopen( $url, 'r');
$xmlstr = fread($dh,8192);
$data = new SimpleXMLElement($xmlstr);
echo $data->name; // Timetable name
table_information
GET: http://app.sharetimetable.com/api/table_information/PUBLIC_ID/
This method return the Timetable basic information: Name, Information, timezone and a list of the Timetable resources.
Parameter
- PUBLIC_ID – Timetable’s Public ID
Return
<!-- Share Timetable API -->
<data>
<version>1.0</version>
<name>Timetable Name</name>
<info>Timetable Information</info>
<timezone></timezone>
<DLS></DLS>
<resources>
<resource>
<id>387</id>
<name>Resource 1 name</name>
<info>Resource 1 Information</info>
</resource>
<resource>
<id>388</id>
<name>Resource 2 name</name>
<info>Resource 2 Information</info>
</resource>
</resources>
</data>
Code Example (php)
$url = "http://app.sharetimetable.com/api/table_information/".$this->o["public_id_str"];
$dh = fopen( $url, 'r');
$xmlstr = fread($dh,8192);
$data = new SimpleXMLElement($xmlstr);
foreach( $data->resources->resource as $res )
{
echo $res->name . $res->info . $res->id;
}
timeslots
GET: http://app.sharetimetable.com/api/timeslots/PUBLIC_ID/RESOURCE_ID/TIME
This method return the Timetable’s resource time-slots information.
Parameter
- PUBLIC_ID – Timetable’s Public ID
- RESOURCE_ID – Resource ID
- TIME – The date of the request in UNIX time.
Return
<!-- Share Timetable API -->
<data>
<version>1.0</version>
<name>Resource Name</name>
<info>Resource Info</info>
<timeslots>
<time>
<start>Start of timeslot</start>
<end>End of timeslot</end>
<available>0</available>
</time>
<time>
<start>1392855800</start>
<end>1392857600</end>
<available>0</available>
</time>
<time>
<start>1392857600</start>
<end>1392859400</end>
<available>0</available>
</time>
<time>
<start>1392859400</start>
<end>1392861200</end>
<available>1</available>
</time>
<time>
<start>1392861200</start>
<end>1392863000</end>
<available>1</available>
</time>
</timeslots>
</data>
Code Example (php)
$time = mktime( 0,0,0, 6, 23, 2014 ); // 23-June-2014
$resource = 388;
$public_id = $this->o["public_id_str"];
$url = "http://app.sharetimetable.com/api/timeslots/$public_id/$resource/$time/";
$dh = fopen( $url, 'r');
$xmlstr = fread($dh,8192);
$data = new SimpleXMLElement($xmlstr);
foreach( $data->timeslots->time as $time )
{
echo "timeslot at ".date( 'G:i', (int)$time->start).
( $time->available ? " " : " Not" )."available."
}
submit
POST: http://app.sharetimetable.com/api/submit/PUBLIC_ID/
This method post the new booking information.
URL Parameter
- PUBLIC_ID – Timetable’s Public ID
POST Parameter
- res_id – Resource ID. (Mandatory)
- start – Start time in UNIX time. (Mandatory)
- end – End time in NIX time. (Mandatory)
- Name – new Booking name. (Mandatory)
- Phone – (optional).
- Email – (optional).
- Comment – will transform new line to <br /> in the site. (optional)
- any other parameter will be saved with the booking.
Note the parameters name case.
Return
Return xml contain result = 1 for success or result =0 if fail and than some descriptive error message.
<!-- Share Timetable API -->
<data>
<version>1.0</version>
<result>1</result>
<error></error>
</data>
Code Example
$url = "http://app.sharetimetable.com/api/submit/".$this->o["public_id_str"];
$params = array(
'res_id' => 3880,
'start' => 1392855800,
'end' => 1392857600,
'Name' => 'New Booking',
'email' => 'me@email.com',
'Comment' => 'Will pay when on time.'
);
$ret = send_post( $url, $params);
$data = new SimpleXMLElement($ret);
if( $data->result == 1 )
{
echo "Booking made successfully";
}
Errors
In case of an error in any one of the above the return xml will be similer to the ‘submit’ result with some error description.
Versions
API version contain major and minor numbers. As API evolved the minor numbers will progress but backward compatibility will retained. A major change in the API may not retain backward compatibility.