padam87 / gls-bundle
为Symfony提供的GLS API包装器
v0.1.7
2019-01-16 22:14 UTC
Requires
- php: ~5.6|~7.0
- ext-soap: *
- php-http/httplug-bundle: ^1.7
- symfony/config: ^2.8 || ^3.0 || ^4.0
- symfony/dependency-injection: ^2.8.3 || ^3.0.3 || ^4.0
- symfony/options-resolver: ^2.8 || ^3.0 || ^4.0
Requires (Dev)
- php-http/guzzle6-adapter: ^1.1
This package is auto-updated.
Last update: 2024-09-24 22:45:37 UTC
README
GLS (东欧) API包装器用于Symfony
安装
composer require padam87/gls-bundle
配置
padam87_gls: wsdl: 'https://online.gls-hungary.com/webservices/soap_server.php?wsdl&ver=16.12.15.01' tracking_url: 'https://gls-group.eu/app/service/open/rest/HU/en/rstt001?match=%1$s' config: username: '000000000' password: '000000000' senderid: '000000000'
- wsdl:请参考API文档以获取该国家正确的URL
- tracking_url:SOAP API没有提供跟踪包裹的方法,但GLS欧洲有一个开放的API,被GLS网站使用
- config:username、password和senderid是唯一的必需配置选项,但你可以使用任何有效的选项,并将其设置为默认值
可选默认值
padam87_gls: parcel_wsdl: 'https://online.gls-hungary.com/webservices/soap_server.php?wsdl' tracking_url: 'https://gls-group.eu/app/service/open/rest/HU/en/rstt001?match={code}' pod_download_url: 'http://online.gls-hungary.com/tt_getPodsClass.php?userID={userid}&senderID={senderid}&pclFrom={code_from}&pclTo={code_to}&lang=hu&directDownload=1&fileType=PDF' config: # Required userid: ~ # Required, Example: required for pod download, GLS usually forgets to provide it unless you ask username: ~ # Required password: ~ # Required senderid: ~ # Required sender_name: 'x' sender_address: 'x' sender_city: 'x' sender_zipcode: 'x' sender_country: 'HU' sender_contact: 'x' sender_phone: 'x' sender_email: 'x' pcount: 1 printertemplate: 'A6' printit: true
使用方法
创建包裹
$api = $this->get('padam87_gls.parcel_api'); $response = $api->createParcel( [ 'consig_address' => $sa->getStreet(), 'consig_city' => $sa->getCity(), 'consig_country' => $sa->getCountry(), 'consig_name' => $sa->getRecipient(), 'consig_zipcode' => $sa->getZipCode(), 'consig_contact' => $user->getName(), 'consig_phone' => $user->getPhone(), 'consig_email' => $user->getEmail(), 'content' => $order->getCode(), 'pickupdate' => (new \DateTime('tomorrow'))->format('Y-m-d'), ] ); if (isset($response['successfull']) && $response['successfull']) { $pdf = base64_decode($response['pdfdata']); $pcls = $response['pcls']; }
包裹信息(跟踪)
$api = $this->get('padam87_gls.tracking_api'); if (false !== $info = $api->getParcelInformation('00')) { $status = $info['progressBar']['statusInfo']; }
API还允许在一次请求中获取多个包裹
$provider->getParcelInformation('00,01', true)
返回的值将是一个数组,其中个别跟踪码是键。
POD下载
$api = $this->get('padam87_gls.pod_download_api'); $pdf = $api->downloadPod($trackingCode); if (null !== $pdf) { // file_put_contents($path, $pdf); }