indego php lib
1.0.0
私は、常に手続き上のPHPを行うのではなく、オブジェクト指向に慣れているため、PHPでほとんど馬鹿げています。私の旅で、私はフィラデルフィア・インデゴ・バイク・シェア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スクリプトは、 Indegoクラス/ライブラリを使用してCitys APIから自転車共有データを取得する楽しいコマンドラインPHPスクリプトです。