aardwarq/aardwarq-php

PHP client for aardwarq.com API

dev-master 2015-09-15 21:40 UTC

This package is not auto-updated.

Last update: 2024-03-16 14:25:06 UTC


README

Software License

This is the PHP API client for Aardwarq.com.

Install

Via Composer

$ composer require aardwarq/aardwarq-php

Usage

// Configure Aardwarq API Client
$provider = new Aardwarq\Api\OAuth2Provider([
    'clientId'     => 'CLIENT_ID',
    'clientSecret' => 'CLIENT_SECRET',
    'redirectUri'  => 'http://aardwarq.com/'
]);

$token = $provider->getAccessToken('clientCredentials');
$api = new Aardwarq\Api\Client($token->accessToken);

// You can set defaults for every event
\Aardwarq\Api\Event\Event::setDefaults([
    'context' => 'CLI', // 
    'environment' => 'development',
    'version' => 'v0.1.1', // Version of your app
]);

// Register exception handler
set_exception_handler(function (\Exception $exception) use ($api) {
    echo 'Handling!';
    $apiException = new \Aardwarq\Api\Event\Exception();
    $apiException
        ->setMessage($exception->getMessage())
        ->setStackTrace($exception->getTrace())
    ;

    $result = $api->send($apiException);
});

Credits

License

The MIT License (MIT). Please see License File for more information.