An unofficial PHP SDK for Madrid's municipal bus company (EMT) OpenData API.
Via Composer
$ composer require carlosafonso/emt-sdk-php
You'll need a set of authentication credentials issued by the EMT OpenData team. These credentials can be obtained here: http://opendata.emtmadrid.es/Formulario.
Create an instance of the SDK client passing the credentials described above:
$clientId = 'FOO.BAR.BAZ';
$passkey = 'ABCDEFGH-1234-ABCD-1234-ABCDEFGHIJKL'
$client = new Afonso\Emt\BusClient($clientId, $passkey);
Then call any of the available methods:
$data = $client->getRouteLines([123], new \DateTime());
print_r($data);
Which should output something like this (truncated for readability):
Array
(
[0] => stdClass Object
(
[line] => 123
[secDetail] => 10
[orderDetail] => 1
[node] => 1425
[distance] => 0
[distancePreviousStop] => 0
[name] => PZA.DE LEGAZPI-MAESTRO ARBOS
[latitude] => 40.390813555735
[longitude] => -3.6951516754786
)
[1] => stdClass Object
(
[line] => 123
[secDetail] => 10
[orderDetail] => 1
[node] => 930
[distance] => 839
[distancePreviousStop] => 839
[name] => ANTONIO LOPEZ-AV.CORDOBA
[latitude] => 40.386984182818
[longitude] => -3.6982344337479
)
)
Each web service has its own client implementation:
$busClient = new Afonso\Emt\BusClient($clientId, $passkey);
$geoClient = new Afonso\Emt\GeoClient($clientId, $passkey);
/* (additional clients are on the works) */
The current version of this library exposes all API endpoints from the BUS web service (http://opendata.emtmadrid.es/Servicios-web/BUS).
Additional services are expected to be implemented soon.
Please see CHANGELOG for more information on what has changed recently.
$ composer test
Please see CONTRIBUTING and CONDUCT for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.