Fedex REST API project, adapted for PHP >=7, guzzle>=7 and later. Should also work with PHP 8.0 but has not been tested.
To install the bindings via Composer, add the following to composer.json:
composer require be-lenka/fedex-php-sdkor
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/be-lenka/fedex-php-sdk.git"
}
],
"require": {
"be-lenka/fedex-php-sdk": "*@dev"
}
}Then run composer install
Download the files and include autoload.php:
<?php
require_once('/path/to/vendor/autoload.php');<?php
require_once(__DIR__ . '/vendor/autoload.php');
$auth = new \belenka\fedex\Authorization\Authorize();
if($productionMode) {
$auth->useProduction();
}
$auth->setClientId('<clientId>');
$auth->setClientSecret('<clientSecret>');
$authResponse = $auth->authorize();$obj = new \belenka\fedex\Services\Track\TrackByTrackingNumberRequest();
// Response from $authResponse->getAccessToken()
$obj->setAccessToken($token);
$obj->setTrackingNumber($number);
$response = $obj->request();$address = new \belenka\fedex\Entity\Address();
$address->setCity('Prague');
$address->setCountryCode('CZ');
$address->setPostalCode('98511');
$address->setStateOrProvince('Czech Republic');
$address->setStreetLines('Jakubská');
$obj = \belenka\fedex\Services\AddressValidation\AddressValidation($address);
// Response from $authResponse->getAccessToken()
$obj->setAccessToken($token);
$obj->setAddress($address);
$response = $obj->request();