PHP code example of hook-sentinel / hook-sentinel-php-sdk

1. Go to this page and download the library: Download hook-sentinel/hook-sentinel-php-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hook-sentinel / hook-sentinel-php-sdk example snippets


use HookSentinel\Client;

$apiKey = 'your-api-key';
$client = new Client($apiKey, 'https://your-instance-url');

use HookSentinel\Objects\Endpoint;

$endpoint = new Endpoint();
$endpoint->name = 'Webhook Name';
$endpoint->endpointType = 'sent';
$endpoint->url = 'https://example.com/webhooks';
$endpoint->description = 'My Webhook';
$endpoint->method = 'POST';
$endpoint->response = 'response data';

$response = $client->endpoints->create($endpoint);

$client->events->endpointSignatureKey = "your-signature-key";
$client->events->endpointId = 'your-endpoint-id';

$client->events->send([
    'foo' => 'bar',
    'message' => 'This is a test event'
]);

$secretKey = 'your-secret-key';
$eventData = $client->events->getEventData($secretKey);

print_r($eventData);

use Symfony\Component\HttpClient\Exception\ClientException;

try {
    $response = $client->endpoints->create($endpoint);
} catch (ClientException $exception) {
    echo $exception->getResponse()->getContent(false);
}