imoth / frenet-php
将您的PHP应用程序与Frenet API集成的最简单方法。
1.1.7
2019-12-30 21:51 UTC
Requires
- php: ^7.0
- guzzlehttp/guzzle: ^6.3
- monolog/monolog: ^1.17
- php-di/php-di: ^6.0
- tiagosampaio/data-object: ^1.0
- tiagosampaio/event-observer: ^1.0
Requires (Dev)
- codacy/coverage: dev-master
- fzaninotto/faker: ^1.8
- phpmd/phpmd: ^2.6
- phpunit/phpunit: ^6.4
- squizlabs/php_codesniffer: ^3.3
This package is not auto-updated.
Last update: 2024-09-26 17:02:11 UTC
README
这是与Frenet API集成的官方PHP SDK。
关于
这是Frenet API的官方SDK(软件开发工具包)。此SDK旨在帮助PHP系统和Frenet API。
安装
使用composer安装
要使用composer安装,您需要在您的计算机上安装composer,这样您就可以轻松地将此SDK安装到您的项目中。
安装完composer后,您只需要求此SDK即可
> composer require frenet/frenet-php
使用
要在您的PHP系统中开始使用此SDK非常简单。请查看下面的示例,了解如何轻松使用
<?php /** * First we need to require the composer autoloader. */ require_once './vendor/autoload'; /** * This is your token from FRENET API. */ $token = '<YOUR TOKEN COMES RIGHT HERE>'; /** @var \Frenet\ApiInterface $api */ $api = \Frenet\ApiFactory::create($token); /** * Here we will create a quote request for sending to API. * * @var \Frenet\Command\Shipping\QuoteInterface $quote */ $quote = $api->shipping()->quote() ->setRecipientCountry('BR') ->setSellerPostcode('13015300') ->setRecipientPostcode('04011060') ->setShipmentInvoiceValue(100.87) ->addShippingItem('CWZ_75673_P', 1, 2.1, 14, 20, 15, 'Accessories') ->addShippingItem('CWZ_75673_F', 1, 2.1, 14, 20, 17, 'Accessories'); /** * The method `execute()` sends the request and parse the body result to a object type. * * @var \Frenet\ObjectType\Entity\Shipping\QuoteInterface $result */ $result = $quote->execute(); $services = $result->getShippingServices(); /** @var Frenet\ObjectType\Entity\Shipping\Quote\ServiceInterface $service */ foreach ($services as $service) { $price = $service->getShippingPrice(); $carrier = $service->getCarrier(); $deliveryTime = $service->getDeliveryTime(); $responseTime = $service->getResponseTime(); /** Do anything you want with this quotation. */ }