commit c73de9a7f7e0d279ae7ac1201bc98e65dfba5773 Author: adrianshort Date: Tue Jul 20 01:48:27 2010 -0700 diff --git a/sutmoblib-api-example.php b/sutmoblib-api-example.php new file mode 100644 index 0000000..5dd9bbc --- /dev/null +++ b/sutmoblib-api-example.php @@ -0,0 +1,52 @@ +exception. +2. The library is visiting various housebound readers at home. This is on the schedule so the times of this activity are specified but the location is not. +3. The library is at a "normal" stop. We get the arrival/departure times and location for this. +4. The library is between stops or back at base. + + +*/ + +define('ENDPOINT', 'http://projects.adrianshort.co.uk/sutmoblib/location.php'); +$result = json_decode(file_get_contents(ENDPOINT)) or die("Couldn't access the API"); + +if (isset($result->exception)) +{ + $message = sprintf("%s: The library is not running today.", $result->exception); +} +elseif ('HOUSEBOUND' == $result->stop->type) +{ + $message = sprintf("The library is currently visiting housebound readers around the borough until %s.", + $result->stop->depart_12); +} +elseif ('NORMAL' == $result->stop->type) +{ + $message = sprintf("The library is at %s, %s. It will be there until %s.", + $result->stop->location->street, + $result->stop->location->town, + $result->stop->depart_12); +} +else +{ + $message = "The library is between stops or back at base."; +} +?> + + + + Sutton Mobile Library API Example + + +

+

API Result

+
+

Sutton Mobile Library schedule

+ +