miklcct / nwst-mobile-api
这是一个用于调用Citybus / NWFB移动API的PHP包装器
1.0.2
2020-04-19 03:26 UTC
Requires
- php: >=7.3
- ext-json: *
- guzzlehttp/guzzle: ^6.5
Requires (Dev)
- phpunit/phpunit: ^8.5
This package is auto-updated.
Last update: 2024-09-08 23:25:57 UTC
README
此库提供了对Citybus / NWFB移动API的接口。
创建API实例的最简单方法是使用工厂,它会自动从维护者处检索密钥。
use Miklcct\Nwst\ApiFactory; use GuzzleHttp\Client; $api = (new ApiFactory(new Client()))();
以下提供了5个API及其示例用法,所有API都支持异步操作。API的返回类型在下面的phpDoc中说明。
如果API失败,将抛出类型为Miklcct\Nwst\ApiException的异常。
use Miklcct\Nwst\Model\Eta; use Miklcct\Nwst\Model\NoEta; use Miklcct\Nwst\Model\Rdv; use Miklcct\Nwst\Model\Route; use Miklcct\Nwst\Model\RouteStop; use Miklcct\Nwst\Model\StopInfo; use Miklcct\Nwst\Model\Variant; use Miklcct\Nwst\Model\VariantInfo; /** @var Route[] $routes */ $routes = $api->getRouteList()->wait(); /** @var Variant[] $variants */ $variants = $api->getVariantList('970--So_Uk')->wait(); /** @var RouteStop[] $stops */ $stops = $api->getStopList( new VariantInfo( Route::COMPANY_NWFB , Rdv::parse('970-SOU-1') , 1 , 40 , 10632 , Route::INBOUND ) )->wait(); /** @var StopInfo $stop_info */ $stop_info = $api->getRouteInStopList(1554)->wait(); /** @var Eta[]|NoEta $etas */ $etas = $api->getEtaList('970', 32, 1554, Rdv::parse('970-SOU-1'), 'O')->wait();
提供的示例程序为example.php。