PHP code example of gpsinsight / api-client

1. Go to this page and download the library: Download gpsinsight/api-client 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/ */

    

gpsinsight / api-client example snippets


use GpsInsight\Api\V2\GpsInsight;

// Create and configure an SDK object
$gpsInsight = new GpsInsight([
    'username'  => 'johndoe3000',
    'app_token' => '490f5ed342ca8',
]);

// Call the "create" method of the "driver" service
// Note: API authentication is applied automatically by the client library
$result = $gpsInsight->driver->create([
    'lastname' => 'Lindblom',
    'firstname' => 'Jeremy',
    'email' => '[email protected]',
    'timezone' => 'US/Arizona',
]);

print_r($result->getData());

use GpsInsight\Api\V2\GpsInsight;
use GpsInsight\Api\V2\TokenCache\CallbackCache as TokenCallbackCache;

// Create and configure an SDK object
$gpsInsight = new GpsInsight([
    'username'  => 'johndoe3000',
    'app_token' => '490f5ed342ca8',
    'channel' => 'my_custom_app',
    'version' => '2.10.1',
    'token_cache' => new TokenCallbackCache(
        function ($key) {
            return isset($_SESSION['gpsinsight_tokens'][$key])
                ? $_SESSION['gpsinsight_tokens'][$key]
                : null;
        },
        function ($key, $token) {
            $_SESSION['gpsinsight_tokens'][$key] = $token;
        }
    ),
]);