akkroo/apiclient

Akkroo Public API client libraries

v1.0.4 2013-11-05 23:48 UTC

README

Installation

The easiest way to install the API client for PHP is to add the package to your composer.json file.

{
    "require": {
        "akkroo/apiclient": "1.0.1"
    }
}

You can also download the zip and include the files manually.

Usage

Webhook handler

Your webhook receiver script could look something like this:

<?php

require_once 'path/to/autoload.php';

use Akkroo\APIClient\WebHookHandler;
use Akkroo\APIClient\Exceptions\WebHookHandlerException;

$whh = new WebHookHandler(SECRET, PRIVATE_KEY);

try {
    if($whh->verifyHash()) {
        $payload = $whh->getPayload();
    } else {
        $whh->sendHashMismatchResponse();
        exit;
    }
} catch(WebHookHandlerException $e) {
    $whh->sendExceptionResponse($e);
    exit;
}

// do something with $payload

$whh->sendSuccessResponse();