robwittman / php-notifications
There is no license information available for the latest version (v1.0.0) of this package.
PHP bindings for robwittman/notification-server
v1.0.0
2016-10-28 20:17 UTC
Requires
- guzzlehttp/guzzle: 6.2.2
- ramsey/uuid: ^3.5
This package is not auto-updated.
Last update: 2024-11-09 20:50:50 UTC
README
PHP bindings for robbybugatti/notification-server
Example
<?php use Notifier\Notifier; use Notifier\Notification; use Notifier\Connection; $url = 'http://localhost:3000'; $token = 'secret-key'; Notifier::init($url, $token); $connection = new Connection($uid); echo $connection->getId(); # returns 5205d501-8c51-4ae6-a603-0e9ecc3dbd75 $payload = [ 'id' => 12341324, 'data' => [ 'test' => true, ] ]; $event = 'data.created'; $notification = new Notification($event, $payload); try { Notifier::send($uid, $notification); } catch(InvalidAuthorizationException $e) { // AUTH TOKEN invalid } catch(InvalidRequestException $e) { // Your request was improperly formatted } catch(\Exception $e) { // Something else happened } Notifier::ping(); # Pings server, and returns true or false Notifier::info(); #returns array('name' => 'server.name', 'version' => '1.0.0')
For further documentation or examples check the container repo