Skip to content

fleetlog/fleetlog-php

Repository files navigation

fleetlog-php

Fleetlog API wrapper

  • Include the class in your PHP code
  • Set your access_token to FleetlogAPI
  • Make request

Installation

Normally: Include TwitterAPIExchange.php in your application.

Composer: Add to your composer.json file to have FleetlogAPI.php automatically imported into your vendors folder:

{
    "require": {
        "fleetlog/fleetlog-php": "dev-master"
    }
}

Of course, you'll then need to run php composer.phar update.

How To Use

Include the class file

require_once('FleetlogAPI.php');

Obtain an access token (client_credentials grant)

$body = array(
	'grant_type' => 'client_credentials',
	'client_id' => 'yourCLientId',
	'client_secret' => 'yourClientSecret'
);

$customHeaders = ['Content-type: application/x-www-form-urlencoded'];
$fleetlog = new \FleetlogAPI();
$resultBody = $fleetlog->request('token', 'POST', $body, $customHeaders);
echo json_encode($resultBody);

$fleetlog->setAccessToken($resultBody->access_token);
$vehicles =  $fleetlog->request('vehicles', 'GET');
echo json_encode($vehicles);

GET Request Example

[GET] https://api.fleetlog.com.au/v2/vehicles/222

$settings = array(
	'oauth_access_token' => "your_access_token",
);

$requestMethod = 'GET';
$fleetlog = new FleetlogAPI($settings);
echo json_encode($fleetlog->request('vehicles/222', 'GET'));

[GET] https://api.fleetlog.com.au/v2/vehicles/222/positions

$settings = array(
	'oauth_access_token' => "your_access_token",
);

$requestMethod = 'GET';
$fleetlog = new FleetlogAPI($settings);
echo json_encode($fleetlog->request('vehicles/222/positions', 'GET'));

Packages

No packages published

Languages