carlosafonso/emt-sdk-php

Unofficial PHP SDK for Madrid's EMT OpenData API

v0.1.0 2017-01-03 23:02 UTC

This package is auto-updated.

Last update: 2024-12-29 05:13:11 UTC


README

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.