feisu / ups-api
PHP UPS API
Requires
- php: ^5.5 || ^7.0
- guzzlehttp/guzzle: ^6.0
- psr/log: ^1.0
Requires (Dev)
- phpunit/phpunit: ^4.8 || ^5.0
Suggests
- ext-soap: Required if you need the Tradeability API of UPS
This package is not auto-updated.
Last update: 2024-10-03 07:25:41 UTC
README
这个库旨在将所有UPS API封装成一个简单易用的PHP库。它目前涵盖了Quantum View®、跟踪API、运输API、评级API和运输时间API。欢迎贡献。
目录
要求
该库使用PHP 5.5+。
要使用UPS API,您必须从UPS请求访问密钥。对于每个请求,您都必须提供访问密钥、您的UPS用户ID和密码。
安装
建议您通过composer安装PHP UPS API库。为此,运行Composer命令安装PHP UPS API的最新稳定版本
composer require gabrielbull/ups-api
如果不使用composer,还必须包含以下库: Guzzle、Guzzle Promises、[Guzzle PSR7] (https://github.com/guzzle/psr7)、PHP-Fig PSR Log和PHP-Fig HTTP Message。
地址验证类(街级)
地址验证类允许您在街级验证地址。当地址无效时,会提供建议。
注意:UPS有两种地址验证。这是街级选项,它包括正常地址验证类的所有选项,并添加了街级验证。
目前仅支持美国和波多黎各。
示例
$address = new \Ups\Entity\Address();
$address->setAttentionName('Test Test');
$address->setBuildingName('Test');
$address->setAddressLine1('Address Line 1');
$address->setAddressLine2('Address Line 2');
$address->setAddressLine3('Address Line 3');
$address->setStateProvinceCode('NY');
$address->setCity('New York');
$address->setCountryCode('US');
$address->setPostalCode('10000');
$xav = new \Ups\AddressValidation($accessKey, $userId, $password);
$xav->activateReturnObjectOnValidate(); //This is optional
try {
$response = $xav->validate($address, $requestOption = \Ups\AddressValidation::REQUEST_OPTION_ADDRESS_VALIDATION, $maxSuggestion = 15);
} catch (Exception $e) {
var_dump($e);
}
AddressValidation::validateReturnAVObject()
在上面的代码中$xav->activateReturnObjectOnValidate()
是完全可选的。调用此方法将导致AddressValidation::validate()
返回一个AddressValidationResponse
对象。如果您不调用此方法,validate
将继续像以前那样工作。如果您不调用此方法,将返回一个包含匹配的验证地址或地址模糊时的第一个候选地址的单个对象。
AddressValidationResponse对象提供了许多方法,以便您可以更轻松地查询API响应以确定结果。继续上面的示例,返回一个AddressValidationResponse
对象将允许您更具体地处理各种结果
if ($response->noCandidates()) {
//Do something clever and helpful to let the use know the address is invalid
}
if ($response->isAmbiguous()) {
$candidateAddresses = $response->getCandidateAddressList();
foreach($candidateAddresses as $address) {
//Present user with list of candidate addresses so they can pick the correct one
}
}
if ($response->isValid()) {
$validAddress = $response->getValidatedAddress();
//Show user validated address or update their address with the 'official' address
//Or do something else helpful...
}
参数
地址验证参数是
address
地址对象,如示例中构造的requestOption
三个请求选项之一。请参阅文档。默认 = 地址验证。maxSuggestion
要返回的最大建议数。最大 = 50
简单的地址验证类
简单的地址验证类允许您像前面的类一样进行更广泛的验证。它返回提供的地址的质量评分并提供替代方案。
注意:UPS有两种地址验证。这是简单选项。
目前仅支持美国和波多黎各。
示例
$address = new \Ups\Entity\Address();
$address->setStateProvinceCode('NY');
$address->setCity('New York');
$address->setCountryCode('US');
$address->setPostalCode('10000');
$av = new \Ups\SimpleAddressValidation($accessKey, $userId, $password);
try {
$response = $av->validate($address);
var_dump($response);
} catch (Exception $e) {
var_dump($e);
}
参数
简单地址验证参数是
address
地址对象,如示例中构造的
QuantumView类
QuantumView类允许您请求Quantum View数据订阅。
示例
$quantumView = new Ups\QuantumView($accessKey, $userId, $password);
try {
// Get the subscription for all events for the last hour
$events = $quantumView->getSubscription(null, (time() - 3600));
foreach($events as $event) {
// Your code here
echo $event->Type;
}
} catch (Exception $e) {
var_dump($e);
}
参数
QuantumView参数是
name
用户请求的订阅名称。如果null,将返回所有事件。beginDateTime
获取订阅检索条件的开始日期时间。格式:Y-m-d H:i:s或Unix时间戳。endDateTime
订阅检索的结束日期时间。格式:Y-m-d H:i:s 或 Unix 时间戳。fileName
用户请求的特定订阅的文件名。bookmark
为下一次检索标记文件。
如果您提供了 beginDateTime
,但没有 endDateTime
,则 endDateTime
将默认为当前日期时间。
要使用 fileName
参数,请不要提供 beginDateTime
。
跟踪类
跟踪类允许您使用 UPS 跟踪 API 跟踪运货。
使用跟踪号/邮递创新跟踪号的示例
$tracking = new Ups\Tracking($accessKey, $userId, $password);
try {
$shipment = $tracking->track('TRACKING NUMBER');
foreach($shipment->Package->Activity as $activity) {
var_dump($activity);
}
} catch (Exception $e) {
var_dump($e);
}
参数
跟踪参数包括
trackingNumber
包裹的跟踪号。requestOption
可选处理。对于邮递创新,唯一有效的选项是最后活动记录和所有活动记录。
使用参考号的示例
$tracking = new Ups\Tracking($accessKey, $userId, $password);
try {
$shipment = $tracking->trackByReference('REFERENCE NUMBER');
foreach($shipment->Package->Activity as $activity) {
var_dump($activity);
}
} catch (Exception $e) {
var_dump($e);
}
参数
跟踪参数包括
referenceNumber
通过参考号跟踪任何 UPS 包裹或运货的能力。参考号可以是采购订单号、工作号等。参考号是在生成运货时提供的。requestOption
可选处理。对于邮递创新,唯一有效的选项是最后活动记录和所有活动记录。
使用参考号和附加参数的示例
$tracking = new Ups\Tracking($accessKey, $userId, $password);
$tracking->setShipperNumber('SHIPPER NUMBER');
$beginDate = new \DateTime('2016-01-01');
$endDate = new \DateTime('2016-01-31');
$tracking->setBeginDate($beginDate);
$tracking->setEndDate($endDate);
try {
$shipment = $tracking->trackByReference('REFERENCE NUMBER');
foreach($shipment->Package->Activity as $activity) {
var_dump($activity);
}
} catch (Exception $e) {
var_dump($e);
}
参数 shipperNumber、beginDate 和 endDate 是可选的。可以单独设置任何一个参数。这些参数可以帮助在通过参考号跟踪时缩小搜索范围,因为可能会发生参考号不唯一的情况。在通过跟踪号跟踪时,不需要这些参数,因为跟踪号是唯一的。
评级类
费率类允许您使用 UPS 费率 API 获取运货费率。
示例
$rate = new Ups\Rate(
$accessKey,
$userId,
$password
);
try {
$shipment = new \Ups\Entity\Shipment();
$shipperAddress = $shipment->getShipper()->getAddress();
$shipperAddress->setPostalCode('99205');
$address = new \Ups\Entity\Address();
$address->setPostalCode('99205');
$shipFrom = new \Ups\Entity\ShipFrom();
$shipFrom->setAddress($address);
$shipment->setShipFrom($shipFrom);
$shipTo = $shipment->getShipTo();
$shipTo->setCompanyName('Test Ship To');
$shipToAddress = $shipTo->getAddress();
$shipToAddress->setPostalCode('99205');
$package = new \Ups\Entity\Package();
$package->getPackagingType()->setCode(\Ups\Entity\PackagingType::PT_PACKAGE);
$package->getPackageWeight()->setWeight(10);
// if you need this (depends of the shipper country)
$weightUnit = new \Ups\Entity\UnitOfMeasurement;
$weightUnit->setCode(\Ups\Entity\UnitOfMeasurement::UOM_KGS);
$package->getPackageWeight()->setUnitOfMeasurement($weightUnit);
$dimensions = new \Ups\Entity\Dimensions();
$dimensions->setHeight(10);
$dimensions->setWidth(10);
$dimensions->setLength(10);
$unit = new \Ups\Entity\UnitOfMeasurement;
$unit->setCode(\Ups\Entity\UnitOfMeasurement::UOM_IN);
$dimensions->setUnitOfMeasurement($unit);
$package->setDimensions($dimensions);
$shipment->addPackage($package);
var_dump($rate->getRate($shipment));
} catch (Exception $e) {
var_dump($e);
}
参数
rateRequest
必须提供。包含运货详情的 rateRequest 对象。
此费率类尚未完成!当完成时将添加参数。
评级运输时间类
费率时间类允许您获取与费率类相同的运货费率,但响应还将包括时间数据。
示例
$rate = new Ups\RateTimeInTransit(
$accessKey,
$userId,
$password
);
try {
$shipment = new \Ups\Entity\Shipment();
$shipperAddress = $shipment->getShipper()->getAddress();
$shipperAddress->setPostalCode('99205');
$address = new \Ups\Entity\Address();
$address->setPostalCode('99205');
$shipFrom = new \Ups\Entity\ShipFrom();
$shipFrom->setAddress($address);
$shipment->setShipFrom($shipFrom);
$shipTo = $shipment->getShipTo();
$shipTo->setCompanyName('Test Ship To');
$shipToAddress = $shipTo->getAddress();
$shipToAddress->setPostalCode('99205');
$package = new \Ups\Entity\Package();
$package->getPackagingType()->setCode(\Ups\Entity\PackagingType::PT_PACKAGE);
$package->getPackageWeight()->setWeight(10);
// if you need this (depends of the shipper country)
$weightUnit = new \Ups\Entity\UnitOfMeasurement;
$weightUnit->setCode(\Ups\Entity\UnitOfMeasurement::UOM_KGS);
$package->getPackageWeight()->setUnitOfMeasurement($weightUnit);
$dimensions = new \Ups\Entity\Dimensions();
$dimensions->setHeight(10);
$dimensions->setWidth(10);
$dimensions->setLength(10);
$unit = new \Ups\Entity\UnitOfMeasurement;
$unit->setCode(\Ups\Entity\UnitOfMeasurement::UOM_IN);
$dimensions->setUnitOfMeasurement($unit);
$package->setDimensions($dimensions);
$shipment->addPackage($package);
$deliveryTimeInformation = new \Ups\Entity\DeliveryTimeInformation();
$deliveryTimeInformation->setPackageBillType(\Ups\Entity\DeliveryTimeInformation::PBT_NON_DOCUMENT);
$pickup = new \Ups\Entity\Pickup();
$pickup->setDate("20170520");
$pickup->setTime("160000");
$shipment->setDeliveryTimeInformation($deliveryTimeInformation);
var_dump($rate->shopRatesTimeInTransit($shipment));
} catch (Exception $e) {
var_dump($e);
}
参数
rateRequest
必须提供。包含运货详情的 rateRequest 对象。
此费率时间类扩展了尚未完成的费率类!当完成时将添加参数。
运输时间类
时间类允许您使用 UPS 时间类获取所有中转时间。
示例
$timeInTransit = new Ups\TimeInTransit($access, $userid, $passwd);
try {
$request = new \Ups\Entity\TimeInTransitRequest;
// Addresses
$from = new \Ups\Entity\AddressArtifactFormat;
$from->setPoliticalDivision3('Amsterdam');
$from->setPostcodePrimaryLow('1000AA');
$from->setCountryCode('NL');
$request->setTransitFrom($from);
$to = new \Ups\Entity\AddressArtifactFormat;
$to->setPoliticalDivision3('Amsterdam');
$to->setPostcodePrimaryLow('1000AA');
$to->setCountryCode('NL');
$request->setTransitTo($to);
// Weight
$shipmentWeight = new \Ups\Entity\ShipmentWeight;
$shipmentWeight->setWeight($totalWeight);
$unit = new \Ups\Entity\UnitOfMeasurement;
$unit->setCode(\Ups\Entity\UnitOfMeasurement::UOM_KGS);
$shipmentWeight->setUnitOfMeasurement($unit);
$request->setShipmentWeight($shipmentWeight);
// Packages
$request->setTotalPackagesInShipment(2);
// InvoiceLines
$invoiceLineTotal = new \Ups\Entity\InvoiceLineTotal;
$invoiceLineTotal->setMonetaryValue(100.00);
$invoiceLineTotal->setCurrencyCode('EUR');
$request->setInvoiceLineTotal($invoiceLineTotal);
// Pickup date
$request->setPickupDate(new DateTime);
// Get data
$times = $timeInTransit->getTimeInTransit($request);
foreach($times->ServiceSummary as $serviceSummary) {
var_dump($serviceSummary);
}
} catch (Exception $e) {
var_dump($e);
}
参数
timeInTransitRequest
必须提供。包含运货详情的 timeInTransitRequest 对象,参见示例。
定位器类
定位器类允许您搜索 UPS Access Point 位置。
示例
$locatorRequest = new \Ups\Entity\LocatorRequest;
$originAddress = new \Ups\Entity\OriginAddress;
$address = new \Ups\Entity\AddressKeyFormat;
$address->setCountryCode('NL');
$originAddress->setAddressKeyFormat($address);
$geocode = new \Ups\Entity\GeoCode;
$geocode->setLatitude(52.0000);
$geocode->setLongitude(4.0000);
$originAddress->setGeoCode($geocode);
$locatorRequest->setOriginAddress($originAddress);
$translate = new \Ups\Entity\Translate;
$translate->setLanguageCode('ENG');
$locatorRequest->setTranslate($translate);
$acccessPointSearch = new \Ups\Entity\AccessPointSearch;
$acccessPointSearch->setAccessPointStatus(\Ups\Entity\AccessPointSearch::STATUS_ACTIVE_AVAILABLE);
$locationSearch = new \Ups\Entity\LocationSearchCriteria;
$locationSearch->setAccessPointSearch($acccessPointSearch);
$locationSearch->setMaximumListSize(25);
$locatorRequest->setLocationSearchCriteria($locationSearch);
$unitOfMeasurement = new \Ups\Entity\UnitOfMeasurement;
$unitOfMeasurement->setCode(\Ups\Entity\UnitOfMeasurement::UOM_KM);
$unitOfMeasurement->setDescription('Kilometers');
$locatorRequest->setUnitOfMeasurement($unitOfMeasurement);
try {
// Get the locations
$locator = new Ups\Locator($accessKey, $userId, $password);
$locations = $locator->getLocations($locatorRequest, \Ups\Locator::OPTION_UPS_ACCESS_POINT_LOCATIONS);
foreach($locations->SearchResults->DropLocation as $location) {
// Your code here
var_dump($location);
}
} catch (Exception $e) {
var_dump($e);
}
参数
定位器类参数包括
locatorRequest
必须提供。包含请求详情的 locatorRequest 对象,参见示例。requestOption
可选。您正在搜索的位置类型。
可交易性类
可交易性类允许您获取国际运货的数据。
- 到岸成本(例如关税)
- 拒绝方筛查器
- 进口合规性
- 出口许可证检测
注意:目前仅实现了到岸成本 API。
警告:可交易性只能通过 SOAP API 获取。因此您需要在您的系统上安装 SOAP 扩展。
示例
// Build request
$landedCostRequest = new \Ups\Entity\Tradeability\LandedCostRequest;
// Build shipment
$shipment = new \Ups\Entity\Tradeability\Shipment;
$shipment->setOriginCountryCode('NL');
$shipment->setDestinationCountryCode('US');
$shipment->setDestinationStateProvinceCode('TX');
$shipment->setResultCurrencyCode('EUR');
$shipment->setTariffCodeAlert(1);
$shipment->setTransportationMode(\Ups\Entity\Tradeability\Shipment::TRANSPORT_MODE_AIR);
$shipment->setTransactionReferenceId('1');
// Build product
$product = new \Ups\Entity\Tradeability\Product;
$product->setProductName('Test');
$tariffInfo = new \Ups\Entity\Tradeability\TariffInfo;
$tariffInfo->setTariffCode('5109.90.80.00');
$product->setTariffInfo($tariffInfo);
$product->setProductCountryCodeOfOrigin('BD');
$unitPrice = new \Ups\Entity\Tradeability\UnitPrice;
$unitPrice->setMonetaryValue(250);
$unitPrice->setCurrencyCode('EUR');
$product->setUnitPrice($unitPrice);
$weight = new Ups\Entity\Tradeability\Weight;
$weight->setValue(0.83);
$unitOfMeasurement = new \Ups\Entity\Tradeability\UnitOfMeasurement;
$unitOfMeasurement->setCode('kg');
$weight->setUnitOfMeasurement($unitOfMeasurement);
$product->setWeight($weight);
$quantity = new \Ups\Entity\Tradeability\Quantity;
$quantity->setValue(5);
$unitOfMeasurement = new \Ups\Entity\Tradeability\UnitOfMeasurement;
$unitOfMeasurement->setCode(\Ups\Entity\Tradeability\UnitOfMeasurement::PROD_PIECES);
$quantity->setUnitOfMeasurement($unitOfMeasurement);
$product->setQuantity($quantity);
$product->setTariffCodeAlert(1);
// Add product to shipment
$shipment->addProduct($product);
// Query request
$queryRequest = new \Ups\Entity\Tradeability\QueryRequest;
$queryRequest->setShipment($shipment);
$queryRequest->setSuppressQuestionIndicator(true);
// Build
$landedCostRequest->setQueryRequest($queryRequest);
try {
// Get the data
$api = new Ups\Tradeability($accessKey, $userId, $password);
$result = $api->getLandedCosts($landedCostRequest);
var_dump($result);
} catch (Exception $e) {
var_dump($e);
}
参数
对于到岸成本调用,参数包括
landedCostRequest
必须提供。包含请求详情的 landedCostRequest 对象,参见示例。
运输类
The Shipping 类允许您注册运货。这也包括退货运货。
运货流程包括 2 个步骤
- 确认:向 UPS 发送信息以获取验证并获取一个可以用来接受运货的摘要。
- 接受:完成运货,将其标记为即将发货。获取标签和附加信息。
请注意,这只是一个示例。您的用例可能需要向 UPS 发送更多或更少的信息。
在示例中使用了 $return 来展示如何处理退货。
示例
// Start shipment
$shipment = new Ups\Entity\Shipment;
// Set shipper
$shipper = $shipment->getShipper();
$shipper->setShipperNumber('XX');
$shipper->setName('XX');
$shipper->setAttentionName('XX');
$shipperAddress = $shipper->getAddress();
$shipperAddress->setAddressLine1('XX');
$shipperAddress->setPostalCode('XX');
$shipperAddress->setCity('XX');
$shipperAddress->setStateProvinceCode('XX'); // required in US
$shipperAddress->setCountryCode('XX');
$shipper->setAddress($shipperAddress);
$shipper->setEmailAddress('XX');
$shipper->setPhoneNumber('XX');
$shipment->setShipper($shipper);
// To address
$address = new \Ups\Entity\Address();
$address->setAddressLine1('XX');
$address->setPostalCode('XX');
$address->setCity('XX');
$address->setStateProvinceCode('XX'); // Required in US
$address->setCountryCode('XX');
$shipTo = new \Ups\Entity\ShipTo();
$shipTo->setAddress($address);
$shipTo->setCompanyName('XX');
$shipTo->setAttentionName('XX');
$shipTo->setEmailAddress('XX');
$shipTo->setPhoneNumber('XX');
$shipment->setShipTo($shipTo);
// From address
$address = new \Ups\Entity\Address();
$address->setAddressLine1('XX');
$address->setPostalCode('XX');
$address->setCity('XX');
$address->setStateProvinceCode('XX');
$address->setCountryCode('XX');
$shipFrom = new \Ups\Entity\ShipFrom();
$shipFrom->setAddress($address);
$shipFrom->setName('XX');
$shipFrom->setAttentionName($shipFrom->getName());
$shipFrom->setCompanyName($shipFrom->getName());
$shipFrom->setEmailAddress('XX');
$shipFrom->setPhoneNumber('XX');
$shipment->setShipFrom($shipFrom);
// Sold to
$address = new \Ups\Entity\Address();
$address->setAddressLine1('XX');
$address->setPostalCode('XX');
$address->setCity('XX');
$address->setCountryCode('XX');
$address->setStateProvinceCode('XX');
$soldTo = new \Ups\Entity\SoldTo;
$soldTo->setAddress($address);
$soldTo->setAttentionName('XX');
$soldTo->setCompanyName($soldTo->getAttentionName());
$soldTo->setEmailAddress('XX');
$soldTo->setPhoneNumber('XX');
$shipment->setSoldTo($soldTo);
// Set service
$service = new \Ups\Entity\Service;
$service->setCode(\Ups\Entity\Service::S_STANDARD);
$service->setDescription($service->getName());
$shipment->setService($service);
// Mark as a return (if return)
if ($return) {
$returnService = new \Ups\Entity\ReturnService;
$returnService->setCode(\Ups\Entity\ReturnService::PRINT_RETURN_LABEL_PRL);
$shipment->setReturnService($returnService);
}
// Set description
$shipment->setDescription('XX');
// Add Package
$package = new \Ups\Entity\Package();
$package->getPackagingType()->setCode(\Ups\Entity\PackagingType::PT_PACKAGE);
$package->getPackageWeight()->setWeight(10);
$unit = new \Ups\Entity\UnitOfMeasurement;
$unit->setCode(\Ups\Entity\UnitOfMeasurement::UOM_KGS);
$package->getPackageWeight()->setUnitOfMeasurement($unit);
// Set Package Service Options
$packageServiceOptions = new \Ups\Entity\PackageServiceOptions();
$packageServiceOptions->setShipperReleaseIndicator(true);
$package->setPackageServiceOptions($packageServiceOptions);
// Set dimensions
$dimensions = new \Ups\Entity\Dimensions();
$dimensions->setHeight(50);
$dimensions->setWidth(50);
$dimensions->setLength(50);
$unit = new \Ups\Entity\UnitOfMeasurement;
$unit->setCode(\Ups\Entity\UnitOfMeasurement::UOM_CM);
$dimensions->setUnitOfMeasurement($unit);
$package->setDimensions($dimensions);
// Add descriptions because it is a package
$package->setDescription('XX');
// Add this package
$shipment->addPackage($package);
// Set Reference Number
$referenceNumber = new \Ups\Entity\ReferenceNumber;
if ($return) {
$referenceNumber->setCode(\Ups\Entity\ReferenceNumber::CODE_RETURN_AUTHORIZATION_NUMBER);
$referenceNumber->setValue($return_id);
} else {
$referenceNumber->setCode(\Ups\Entity\ReferenceNumber::CODE_INVOICE_NUMBER);
$referenceNumber->setValue($order_id);
}
$shipment->setReferenceNumber($referenceNumber);
// Set payment information
$shipment->setPaymentInformation(new \Ups\Entity\PaymentInformation('prepaid', (object)array('AccountNumber' => 'XX')));
// Ask for negotiated rates (optional)
$rateInformation = new \Ups\Entity\RateInformation;
$rateInformation->setNegotiatedRatesIndicator(1);
$shipment->setRateInformation($rateInformation);
// Get shipment info
try {
$api = new Ups\Shipping($accessKey, $userId, $password);
$confirm = $api->confirm(\Ups\Shipping::REQ_VALIDATE, $shipment);
var_dump($confirm); // Confirm holds the digest you need to accept the result
if ($confirm) {
$accept = $api->accept($confirm->ShipmentDigest);
var_dump($accept); // Accept holds the label and additional information
}
} catch (\Exception $e) {
var_dump($e);
}
如果您想要从 $accept 返回的 UPS 运货标签图像数据创建可打印的文件,您可以使用以下类似的方法
$label_file = $order_id . ".gif";
$base64_string = $accept->PackageResults->LabelImage->GraphicImage;
$ifp = fopen($label_file, 'wb');
fwrite($ifp, base64_decode($base64_string));
fclose($ifp);
参数
对于运货 confirm
调用,参数包括
- $validation UPSShipping::REQ* 常量(或 null)。必须提供
- $shipment 运货数据容器。必须提供
- $labelSpec 标签规范数据。可选
- $receiptSpec 运货请求收据规范数据。可选
对于运货 accept
调用,参数包括
- 货件摘要:从ShipConfirm请求中接收到的UPS货件摘要。必需
日志记录
所有构造函数都接受一个与PSR-3兼容的记录器。
除此之外,主UPS类有一个公开方法setLogger
,可以在构造函数运行后设置。
请求和响应(包括XML,无访问键)在DEBUG级别记录。在INFO级别仅报告事件,不记录XML内容。更严重的问题(例如无连接)以更高的严重性记录。
使用Monolog的示例
// Create logger
$log = new \Monolog\Logger('ups');
$log->pushHandler(new \Monolog\Handler\StreamHandler('logs/ups.log', \Monolog\Logger::DEBUG));
// Create Rate object + insert logger
$rate = new Ups\Rate($key, $username, $password, $useIntegration, $log);
许可
PHP UPS API采用MIT许可(MIT)许可。