PHP code example of oktey / api-php-v1

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

    

oktey / api-php-v1 example snippets



namespace App;

// Utiliser l'autoloader composer
erreurs en mode développement
ini_set('display_errors', 1); ini_set('html_errors', 1);

// Création de l'objet API
$Api = new Client('apiId', 'apiSecret');

try {
    // Requête sur l'api
    $response = $Api->get('/customers/lite');

    if ($response->success()) {
        // Récupération des données
        $customers = $response->getData();

        // affichage ;)
        var_dump($customers);
    } else {
        trigger_error(sprintf('Error %d : %s', $response->getStatus(), $response->getMessageError()), E_USER_WARNING);
    }
} catch(Exception $e) {
    // Oops !!!
    trigger_error(sprintf('Api Exception %d : %s', $e->getCode(), $e->getMessage()), E_USER_WARNING);
}
bash
# Si composer n'est pas encore installé
curl -sS https://getcomposer.org/installer | php
mv composer.phar composer

php composer