akkroo/apiclient

This package is abandoned and no longer maintained. No replacement package was suggested.

Akkroo Public API client libraries

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

This package is not auto-updated.

Last update: 2020-01-19 17:07:13 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();