Interact with the WebHooker.io API
Via Composer
composer require webhooker/webhooker-sdk
You must also have Guzzle installed. By default, the package is only compatible with Guzzle 6:
composer require guzzlehttp/guzzle
Instantiate:
$webhooker = Webhooker\Webhooker::usingGuzzle('YOUR-API-KEY');
Add a subscriber:
$subscriber = $webhooker->addSubscriber('Their Name Here');
$subscriber->id;
Add an endpoint for the subscriber to receive messages:
// you can use "jsonSubscription" or "xmlSubscription"
$subscription = $webhooker->subscriber($id)->jsonSubscription($tenantKey, $deliveryUrl, $secret)->save();
$subscription = $webhooker->subscriber($id)->xmlSubscription($tenantKey, $deliveryUrl, $secret)->save();
// additional options for a subscription, e.g. Basic Auth, or "Legacy Payloads"
$subscription = $webhooker->subscriber($id)
->jsonSubscription($tenantKey, $deliveryUrl, $secret)
->basicAuth($username, $password)
->legacyPayload('p_reply')
->save();
$subscription->id;
Send a JSON message:
// $jsonData can be something JSON-able (array/object) or a pre-encoded JSON string
$webhooker->notify('account-1', 'something.happened')->json($jsonData)->send();
Or, because JSON is very common, just pass it directly to the send()
method:
$webhooker->notify('account-1', 'something.happened')->send($jsonData);
Send an XML message:
// $xmlData must be an XML string
$webhooker->notify('account-1', 'something.happened')->xml($xmlData)->send();
Send both XML and JSON messages:
$webhooker->notify('account-1', 'something.happened')->xml($xmlData)->json($jsonData)->send();
Please see CHANGELOG for more information what has changed recently.
composer test
Please see CONTRIBUTING and CONDUCT for details.
If you discover any security related issues, please email dan@radweb.co.uk instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.