hook-sentinel/hook-sentinel-php-sdk
最新稳定版本:1.0.0
Composer 安装命令:
composer require hook-sentinel/hook-sentinel-php-sdk
包简介
A simple SDK for interacting with my API.
关键字:
README 文档
README
HookSentinel PHP SDK is a simple and intuitive library that helps you integrate with the HookSentinel API to manage endpoints and send events.
Installation
Install the SDK via Composer:
composer require hook-sentinel/hook-sentinel-php-sdk
Usage
Initialize the Client
Before making any requests, initialize the client with your API key and the base URL of your instance.
use HookSentinel\Client; $apiKey = 'your-api-key'; $client = new Client($apiKey, 'https://your-instance-url');
Create an Endpoint
Create a new webhook endpoint by providing its details:
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);
Send an Event
Send an event to your webhook endpoint:
$client->events->endpointSignatureKey = "your-signature-key"; $client->events->endpointId = 'your-endpoint-id'; $client->events->send([ 'foo' => 'bar', 'message' => 'This is a test event' ]);
Retrieve Event Data
Get the details of a received event by providing the secret key:
$secretKey = 'your-secret-key'; $eventData = $client->events->getEventData($secretKey); print_r($eventData);
Handling Errors
The SDK throws exceptions for any errors. You can catch and handle them like this:
use Symfony\Component\HttpClient\Exception\ClientException; try { $response = $client->endpoints->create($endpoint); } catch (ClientException $exception) { echo $exception->getResponse()->getContent(false); }
License
This project is licensed under the MIT License.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-10-19