Skip to content

Simplify your webhook distribution infrastructure to a single line of code

License

Notifications You must be signed in to change notification settings

WebHooker/webhooker-sdk-php

Repository files navigation

WebHooker SDK for PHP

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.

About

Simplify your webhook distribution infrastructure to a single line of code

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages