awd-studio / nova-poshta
v0.4.0
2017-11-30 04:43 UTC
Requires
- php: >=5.5 | 7
- ext-json: *
Requires (Dev)
- php-coveralls/php-coveralls: ^2.0@dev
- phpunit/phpunit: ~5.7
README
此包已被弃用且不再维护。作者建议使用awd-studio/novaposhta包代替。
要求
- PHP v5.5或更高版本 (推荐使用PHP 7+)
- Composer包管理器
- API令牌
- Guzzle库或PHP_CURL库用于发送HTTP请求 (可选 - 您可以定义自己的HTTP驱动)Guzzle 或 PHP_CURL
安装
composer require awd-studio/nova-poshta
使用
授权
<?php use NovaPoshta\Settings\Settings; $key = 'myAuthKeyHash'; $settings = Settings::getInstance()->auth($key);
跟踪
<?php use NovaPoshta\Settings\Settings; use NovaPoshta\Models\TrackingDocument; $key = 'myAuthKeyHash'; $settings = Settings::getInstance()->auth($key); $trackNum = '01234567890123'; // Valid track number $status = TrackingDocument::track($settings, $trackNum);
获取分支机构
<?php use NovaPoshta\Settings\Settings; use NovaPoshta\Models\Address; $key = 'myAuthKeyHash'; $settings = Settings::getInstance()->auth($key); /** * Optional parameters. * * @see https://devcenter.novaposhta.ua/docs/services/556d7ccaa0fe4f08e8f7ce43/operations/556d8211a0fe4f08e8f7ce45 */ $options = [ 'BicycleParking' => '1', 'TypeOfWarehouseRef' =>'9a68df70-0267-42a8-bb5c-37f427e36ee4', 'PostFinance' => '1', 'CityName' =>'Київ', 'CityRef' => '20982d74-9b6c-11e2-a57a-d4ae527baec3', ]; // Or set city REF for quick searching: // $options = [ // 'SettlementRef' => 'e71629ab-4b33-11e4-ab6d-005056801329' // ]; $address = Address::getBranches($settings, $options);
获取地址引用
<?php use NovaPoshta\Settings\Settings; use NovaPoshta\Models\Address; $key = 'myAuthKeyHash'; $settings = Settings::getInstance()->auth($key); $address = new Address($settings); $response = $address->getAreas(); // Areas $options = [ 'CityRef' => 'ebc0eda9-93ec-11e3-b441-0050568002cf', ]; $response = $address->getStreet($options); // Streets $response = $address->getSettlements($options); // Settlements
在线搜索方法
<?php use NovaPoshta\Settings\Settings; use NovaPoshta\Models\Address; $key = 'myAuthKeyHash'; $settings = Settings::getInstance()->auth($key); $address = new Address($settings); // Just start typing, no needed save values to database! $options = [ 'CityName' => 'К', //'CityName' => 'Ки', //'CityName' => 'Киї', ]; $response = $address->searchSettlements($options); // Get towns list $options = [ 'StreetName' => 'Шев', 'SettlementRef' => 'e715719e-4b33-11e4-ab6d-005056801329', 'Limit' => 10, ]; $response = $address->searchSettlements($options); // Get streets
常见词典
<?php use NovaPoshta\Settings\Settings; use NovaPoshta\Models\Common; use NovaPoshta\Models\Address; $key = 'myAuthKeyHash'; $settings = Settings::getInstance()->auth($key); $recipientCityRef = '8d5a980d-391c-11dd-90d9-001a92567626'; $common = new Common($settings); $response = $common->getCargoTypes(); // Or $response = $common->getPalletsList(); // Or $response = $common->getMessageCodeText(); // Or $response = $common->getTimeIntervals($recipientCityRef); // Get warehouse types $address = new Address($settings); $response = $address->getWarehouseTypes();
详情请见此处。所有方法均已实现。