PHP code example of idealizetecnologia / frenet-php
1. Go to this page and download the library: Download idealizetecnologia/frenet-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
idealizetecnologia / frenet-php example snippets
/**
* First we need to oload';
/**
* 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. */
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.