Wallogit.com
2017 © Pedro Peláez
A module to fetch Santander Cycle availability within a distance of specified locations.
A module to fetch Santander Cycle hire locations within a distance of specified locations. Read more on the blog., (*1)
To include this package in your project, use composer:, (*2)
composer install jessicadigital/tflcycles, (*3)
To fetch locations, first create a new instance of the TflCycles class:, (*4)
$tflcycles = new \JessicaDigital\TflCycles\TflCycles();, (*5)
Now, specify your location(s) to find nearby hire stations:, (*6)
$tflcycles->addLocation($latitude, $longitude);, (*7)
You must specify one or more locations., (*8)
Next, set the search distance (in metres), e.g., (*9)
$tflcycles->setDistance(2000);, (*10)
for 2km. This will find all bike hire locations within 2km of any of the specified locations. The default is 1000m., (*11)
Now, perform a search. Use the find() method to return an array of stations, or save($filename) to save this array directly to a file., (*12)
This example will fetch all cycle hire stations within 500m of Euston and Waterloo rail stations and save to a file called cycles.json:, (*13)
// Create object
$tflcycles = new \JessicaDigital\TflCycles\TflCycles();
// Add location - Euston Station
$tflcycles->addLocation(51.5290371, -0.1368696);
// Add location - Waterloo Station
$tflcycles->addLocation(51.5031686, -0.1144991);
// Change distance to 500m
$tflcycles->setDistance(500);
// Save the found locations to a file called cycles.json
$tflcycles->save('cycles.json');
This package uses the TfL Santander Cycle API. Please abide by their Terms and Conditions., (*14)
Do not make repeated requests to the API - the data is only updated every five minutes. The recommended approach for using this package is to set up a scheduled CRON job to fetch and cache the data you need., (*15)
This project has no connection with TfL or the bike hire scheme; it was created as part of a development project and released for the community to enjoy., (*16)