Usage Example - HiberniaCDN/api-client-php GitHub Wiki
# Create a client
$client = new \HiberniaCDN\APIClient\HTTPClient();
# Try to log in
try {
# Try to log in
$response = $client->post(
'/login',
['email' => '[email protected]', 'password' => 'My Secret Password']
);
# Getting authorization token from response
$authToken = $response['bearer_token'];
# Request Account's sites list
$sites = $client->get(
'/accounts/' . $response['user']['account']['id'] . '/sites',
$authToken
);
# Output
echo sizeof($sites) . ' sites found' . PHP_EOL;
} catch (\HiberniaCDN\APIClient\Exception $x) {
# Process errors
echo 'Error!' . PHP_EOL;
echo ' > Status: ' . $x->getApiResponseStatus() . PHP_EOL;
echo ' > Text: ' . $x->getServerErrorMessage() . PHP_EOL;
echo ' > Details: ' . $x->getServerErrorDetails() . PHP_EOL;
echo ' > Raw Response: ' . $x->getApiResponse() . PHP_EOL;
}