This is the Convoy PHP SDK. This SDK contains methods for easily interacting with Convoy's API. Below are examples to get you started. For additional examples, please see our official documentation at (https://convoy.readme.io/reference)
To install the package, you will need to be using Composer in your project.
The Convoy PHP SDK is not hard coupled to any HTTP Client such as Guzzle or any other library used to make HTTP requests. The HTTP Client implementation is based on PSR-18. This provides you with the convenience of choosing what PSR-7 and HTTP Client you want to use.
To get started quickly,
composer require frain/convoy symfony/http-client nyholm/psr7
Next, import the convoy
module and setup with your auth credentials.
use Convoy\Convoy;
$convoy = new Convoy(["api_key" => "your_api_key", "project_id" => "your_project_id"]);
An endpoint represents a target URL to receive events.
$endpointData = [
"name" => "Default Endpoint",
"url" => "https://0d87-102-89-2-172.ngrok.io",
"description" => "Default Endpoint",
"secret" => "endpoint-secret",
"events" => ["*"]
];
$response = $convoy->endpoints()->create($endpointData);
$endpointId = "01GTVFSGBAH8NJTMT5Y1ENE218";
$endpointData = [
"name" => "Default Endpoint",
"url" => "https://0d87-102-89-2-172.ngrok.io",
"description" => "Default Endpoint",
"secret" => "endpoint-secret",
"events" => ["*"]
];
$response = $convoy->endpoints()->update($endpointId, $endpointData);
To send an event, you'll need the uid
from the endpoint we created earlier.
$eventData = [
"endpoint_id" => $endpointId,
"event_type" => "payment.success",
"data" => [
"event" => "payment.success",
"data" => [
"status" => "Completed",
"description" => "Transaction Successful",
"userID" => "test_user_id808"
]
]
];
$response = $convoy->events()->create($eventData);
composer test
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.