Unofficial PHP SDK for Madrid's EMT OpenData API
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
tests
.gitattributes
.gitignore
.scrutinizer.yml
.styleci.yml
.travis.yml
CHANGELOG.md
CONDUCT.md
CONTRIBUTING.md
ISSUE_TEMPLATE.md
LICENSE
LICENSE.md
PULL_REQUEST_TEMPLATE.md
README.md
composer.json
composer.lock
phpunit.xml.dist

README.md

emt-sdk-php

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

An unofficial PHP SDK for Madrid's municipal bus company (EMT) OpenData API.

Install

Via Composer

$ composer require carlosafonso/emt-sdk-php

Usage

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) */

Available methods

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.

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email carlos.afonso.perez@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.