webhooker/webhooker-sdk

SDK for communicating with the WebHooker.io API

0.4.0 2024-03-27 14:18 UTC

This package is auto-updated.

Last update: 2024-11-27 15:58:19 UTC


README

Latest Version on Packagist Software License Build Status Total Downloads

Interact with the WebHooker.io API

Install

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

Usage

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();

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email dan@radweb.co.uk instead of using the issue tracker.

License

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