From c73de9a7f7e0d279ae7ac1201bc98e65dfba5773 Mon Sep 17 00:00:00 2001 From: adrianshort Date: Tue, 20 Jul 2010 01:48:27 -0700 Subject: [PATCH] --- sutmoblib-api-example.php | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 sutmoblib-api-example.php 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

+ +