cop-cos / cop-guzzle-sdk
COSCOShipping COP SDK - PHP版本
1.0.2
2021-05-25 05:14 UTC
Requires
- php: >=7.0
- ext-openssl: *
- guzzlehttp/guzzle: >=7.2
This package is not auto-updated.
Last update: 2024-10-01 22:18:37 UTC
README
安装
- 通过 Composer 在 composer.json 中安装。
"require": { "php": ">=7.0", "ext-openssl": "*", "guzzlehttp/guzzle": ">=7.2", "cop-cos/cop-guzzle-sdk":">=1.0.0" }
并执行安装
composer install
要求
- PHP 7.0+
- guzzlehttp/guzzle 7.2+
用法
<?php require_once 'vendor/autoload.php'; use COP\Client\COPClient; use GuzzleHttp\Exception\RequestException; use GuzzleHttp\HandlerStack; /**************************************************************** * Setting up HttpClient ... ***************************************************************/ $stack = HandlerStack::create(); $copClient = \COP\Client\COPClient::builder('YOUR_API_KEY', 'YOUR_SECRET_KEY')->withHttpHandlerStack($stack)->build(); $httpClient = new \GuzzleHttp\Client(['handler' => $stack]); /****************************************************************/ try { $resp = $httpClient->request('GET', 'https://api.lines.coscoshipping.com/service/info/tracking/6103622780?numberType=bl', [ // Replace with actual URL 'headers' => [ 'Accept' => 'application/json' ], 'version' => 1.1 ]); echo $resp->getStatusCode() . ' ' . $resp->getReasonPhrase() . "\n"; echo $resp->getBody() . "\n"; } catch (RequestException $e) { echo $e->getMessage() . "\n"; if ($e->hasResponse()) { echo $e->getResponse()->getStatusCode() . ' ' . $e->getResponse()->getReasonPhrase() . "\n"; echo $e->getResponse()->getBody(); } return; }
许可证
MIT许可证 (MIT)
版权所有 (c) 2018 Cees-Jan Kiewiet
在此前提下,任何人无需支付费用即可获得此软件及其相关文档副本(“软件”),自由使用软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本,以及允许软件提供方进行上述行为,前提是必须遵守以下条件
上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。
软件按“原样”提供,不提供任何形式的保证,无论是明示的还是暗示的,包括但不限于适销性、特定用途适用性和非侵权性保证。在任何情况下,作者或版权所有者不对任何索赔、损害或其他责任承担责任,无论是基于合同、侵权或其他原因,源于、涉及或与软件或其使用或其他交易有关。