ozdemirburak / skyscanner-php
此包已被放弃,不再维护。未建议替代包。
Skyscanner API 的非官方 PHP SDK
2.3.0
2021-11-16 13:19 UTC
Requires
- php: ~7.1
- guzzlehttp/guzzle: ~6.0
Requires (Dev)
- phpunit/phpunit: ~6.0|~7.0
README
这是一个非官方的 PHP SDK,用于支持 Skyscanner API(https://skyscanner.github.io/slate/)中的航班、租车、酒店、本地化和地点服务。
目前,所有服务都已实现。除了酒店服务之外,所有服务都已测试,因为找不到任何有效的 API 密钥,并且与 Skyscanner 的人联系无果。
安装
通过 Composer
$ composer require ozdemirburak/skyscanner-php
对于 PHP 7.0 及以下版本,请使用 ~1.0
。
使用方法
有关方法和参数的更详细信息,请参阅 wiki。
以下可以找到如何使用这些方法的简单演示,或检查 测试 以获取更多高级示例。
航班:实时定价
use OzdemirBurak\SkyScanner\Travel\Flights\LivePricing; $pricing = new LivePricing($apiKey = 'your-api-key'); $pricing->setParameters([ 'adults' => 1, 'country' => 'GB', 'currency' => 'GBP', 'destinationPlace' => 'IST', 'locale' => 'en-GB', 'originPlace' => 'LHR', 'outboundDate' => date('Y-m-d', strtotime('+1 week')), 'stops' => 0 ]); $flights = $pricing->getFlights($onlyFirstAgentPerItinerary = true);
航班:浏览缓存
use OzdemirBurak\SkyScanner\Travel\Flights\BrowseCache; $cache = new BrowseCache($apiKey = 'your-api-key'); $cache->setParameters([ 'country' => 'TR', 'currency' => 'TRY', 'destinationPlace' => 'IST', 'locale' => 'tr-TR', 'originPlace' => 'LHR', 'outboundPartialDate' => date('Y-m-d', strtotime('+1 week')), ]); $quotes = $cache->getPrices()['Quotes'];
租车:实时定价
use OzdemirBurak\SkyScanner\Travel\CarHire\LivePricing; $pricing = new LivePricing($apiKey = 'your-api-key'); $pricing->setParameters([ 'country' => 'GB', 'currency' => 'GBP', 'dropoffplace' => 'ADB', 'dropoffdatetime' => date('Y-m-d\TH:i', strtotime('+2 week')), 'locale' => 'en-GB', 'pickupplace' => 'IST', 'pickupdatetime' => date('Y-m-d\TH:i', strtotime('+1 week')), 'driverage' => 21 ]); $cars = $pricing->getCars();
酒店:实时定价
use OzdemirBurak\SkyScanner\Travel\Hotels\LivePricing; $pricing = new LivePricing($apiKey = 'your-api-key'); $pricing->setParameters([ 'country' => 'TR', 'currency' => 'TRY', 'entity_id' => 27544008, 'checkin_date' => date('Y-m-d', strtotime('+1 week')), 'checkout_date' => date('Y-m-d', strtotime('+2 week')), 'locale' => 'tr-TR' ]); $hotels = $pricing->getHotels();
本地化:货币
use OzdemirBurak\SkyScanner\Localisation\Currency; $currency = new Currency($apiKey = 'your-api-key'); $currencies = $currency->get();
本地化:区域设置
use OzdemirBurak\SkyScanner\Localisation\Locale; $locale = new Locale($apiKey = 'your-api-key'); $locales = $locale->get();
本地化:市场
use OzdemirBurak\SkyScanner\Localisation\Market; $market = new Market($apiKey = 'your-api-key')); $market->setLocale('en-GB'); $countries = $market->get();
地点
use OzdemirBurak\SkyScanner\PlacesService; $places = new PlacesService($apiKey = 'your-api-key'); $geoCatalog = $places->get(); $list = $places->getList('UK', 'GBP', 'en-GB', 'istanbul'); $information = $places->getInformation('UK', 'GBP', 'en-GB', 'CDG-sky'); $hotels = $places->getHotels('UK', 'EUR', 'en-GB', 'paris');
变更日志
有关最近更改的更多信息,请参阅 CHANGELOG。
测试
$ composer test
贡献
有关详细信息,请参阅 CONTRIBUTING。
致谢
许可证
MIT 许可证(MIT)。有关更多信息,请参阅 许可证文件。