webhooker / webhooker-sdk
SDK for communicating with the WebHooker.io API
Installs: 1 032
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 5
Forks: 1
Open Issues: 0
Requires
- php: >=5.5.0
- guzzlehttp/psr7: ^2.4
Requires (Dev)
- guzzlehttp/guzzle: ^7.8.1
- mockery/mockery: ^0.9.4
- phpunit/phpunit: ^9.0.0
- scrutinizer/ocular: ~1.1
- squizlabs/php_codesniffer: ~2.3
Suggests
- guzzlehttp/guzzle: To use as the HTTP library (^6.1)
This package is auto-updated.
Last update: 2024-10-27 15:51:26 UTC
README
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.