akkroo / apiclient
Akkroo Public API client libraries
Installs: 3 226
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 14
Forks: 0
Open Issues: 0
Requires
- php: >=5.3.0
Requires (Dev)
- monolog/monolog: 1.6.*
- phpunit/phpunit: 3.7.*
Suggests
- monolog/monolog: A PSR-3 compatible logger which can be passed to the library to perform logging
- psr/log: This provides the definition for a logger which is compatible with the library
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();