2017 © Pedro Peláez
 

library mygeotab-php

Unofficial PHP client for the MyGeotab API

image

geotab/mygeotab-php

Unofficial PHP client for the MyGeotab API

  • Tuesday, March 29, 2016
  • by colonelchlorine
  • Repository
  • 5 Watchers
  • 2 Stars
  • 466 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 1 % Grown

The README.md

MyGeotab PHP API Client

Packagist, (*1)

Provides a PHP client that can easily make API requests to a MyGeotab server., (*2)

Installation

You can use composer and run the following command into your own repo:, (*3)

composer require geotab/mygeotab-php

This repository requires PHP >=7.1, but if you're going to try integrate this into older versions then you can look at the code in src directly., (*4)

Quick start

$api = new Geotab\API("user@example.com", "password", "DatabaseName", "my.geotab.com");
$api->authenticate();

$api->get("Device", ["resultsLimit" => 1], function ($results) {
    var_dump($results);
}, function ($error) {
    var_dump($error);
});

Instead of using the callback syntax, you can simply use the return result directly. Keep in mind, if an error occurs you won't be informed! It will throw as a MyGeotabException, so remember to use try & catch., (*5)

$toDate = new DateTime();
$fromDate = new DateTime();
$fromDate->modify("-1 month");

try {
    $violations = $api->get("DutyStatusViolation", [
        "search" => [
            "userSearch" => ["id" => "b1"],
            "toDate" => $toDate->format("c"),   // ISO8601, or could use "2018-11-03 00:53:29.370134"
            "fromDate" => $fromDate->format("c")
        ],
        "resultsLimit" => 10
    ]);
} catch (Exception $e) {
    // Handle this or return
}

echo "The driver has " . count($violations) . " violations!";

Contributing

To build this repo, you should start by running:, (*6)

composer update

Feel free to clone and open a new Pull Request with any suggested changes., (*7)

Examples

In the examples folder, you can see the "Top Speeding Violations" example that was presented in the Dev Channel video. You can use the PHP built-in web server to test out the example at http://localhost:7000 by running:, (*8)

php -S localhost:7000 -t examples/top-speeding-violations/web

The Versions

29/03 2016

dev-master

9999999-dev

Unofficial PHP client for the MyGeotab API

  Sources   Download

Apache2

The Requires

  • php >=5.3.3

 

The Development Requires

api sdk geotab mygeotab

29/03 2016

1.0.0

1.0.0.0

Unofficial PHP client for the MyGeotab API

  Sources   Download

Apache2

The Requires

  • php >=5.3.3

 

The Development Requires

api sdk geotab mygeotab