Initialize the client

Let's begin by initializing the API client in our form.php file. Copy this code:

<?php
use Deskpro\API\DeskproClient;
use Deskpro\API\Exception\APIException;

include(__DIR__ . '/vendor/autoload.php');

// Pass the URL to your Deskpro instance when creating the client.
$client = new DeskproClient('http://deskpro.company.com');

// `Many API methods require authentication. Set the ID of the user
// to authenticate with and either the auth key or token.`
$client->setAuthKey(1, 'dev-admin-code');
// $client->setAuthToken(1, 'AWJ2BQ7WG589PQ6S862TCGY4');

try {
    $resp = $client->get('/articles');
    print_r($resp->getData());
    print_r($resp->getMeta());
} catch (APIException $e) {
    echo $e->getMessage();
}

Run this page in your browser and you'll see a bunch of JSON output. Something like:

Last updated