indego php lib
1.0.0
我主要是在愚弄PHP,以使對象取向更習慣,而不是一直進行程序PHP。在我的旅程中,我為費城Indego Bike Share API製作了可重複使用的PHP庫!
如果您認為這個圖書館很有趣,請查看費城吉特布市!
與提供的Indego類結合使用時,以下代碼將在下一節中生成示例輸出:
// Require the Indego class
require_once('Indego.class.php');
// Instantiate the Indego class which will immediately discover all of the stations
$indego = new Indego;
// Just get "university" stations
$uni_stations = $indego->getStations('university');
print_r($uni_stations);
向getStations()提供一個參數/過濾器以返回站點列表,僅限制了Indego類中的結果。
不幸的是,似乎沒有用於使用的API的明顯文檔量,也似乎沒有任何參數可以限制從API中檢索的站點。
在沒有任何參數的情況下呼叫getStations()將返回所有列表(當前,103)站!
$ php example.php
Array
(
[3008] => stdClass Object
(
[addressStreet] => 1076 Berks Street
[addressCity] => Philadelphia
[addressState] => PA
[addressZipCode] => 19122
[bikesAvailable] => 9
[closeTime] => 23:58:00
[docksAvailable] => 8
[eventEnd] =>
[eventStart] =>
[isEventBased] =>
[isVirtual] =>
[kioskId] => 3008
[kioskPublicStatus] => Active
[name] => Temple University Station
[openTime] => 00:02:00
[publicText] =>
[timeZone] => Eastern Standard Time
[totalDocks] => 19
[trikesAvailable] => 0
[coordinates] => Array
(
[0] => -75.14973
[1] => 39.98082
)
)
[3020] => stdClass Object
(
[addressStreet] => 3051 South St.
[addressCity] => Philadelphia
[addressState] => PA
[addressZipCode] => 19147
[bikesAvailable] => 18
[closeTime] => 23:58:00
[docksAvailable] => 17
[eventEnd] =>
[eventStart] =>
[isEventBased] =>
[isVirtual] =>
[kioskId] => 3020
[kioskPublicStatus] => Active
[name] => University City Station
[openTime] => 00:02:00
[publicText] =>
[timeZone] => Eastern Standard Time
[totalDocks] => 35
[trikesAvailable] => 0
[coordinates] => Array
(
[0] => -75.18986
[1] => 39.94887
)
)
)
隨附的indego-cli.php腳本是我編寫的一個有趣的命令行PHP腳本,它使用Indego Class/Library來獲取來自Citys API的自行車共享數據!