1. Go to this page and download the library: Download sendkuy/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/ */
sendkuy / sdk example snippets
use SendKuy\SendKuy;
$sendkuy = new SendKuy(getenv('SENDKUY_API_KEY'));
$messages = $sendkuy->messages()->send([
'channel' => 'whatsapp',
'to' => ['+6281234567890'],
'body' => 'Your order is on its way.',
]);
echo $messages[0]->id; // msg_...
foreach ($sendkuy->contacts()->list(['limit' => 100])->autoPaginate() as $contact) {
echo $contact->id;
}
$page = $sendkuy->contacts()->list();
$page->data; // this page
$page->hasMore;
$page->nextPage(); // null on the last page
use SendKuy\Exceptions\InvalidRequestException;
use SendKuy\Exceptions\RateLimitException;
use SendKuy\Exceptions\SendKuyException;
try {
$sendkuy->messages()->send($params);
} catch (InvalidRequestException $e) {
$e->getErrorCode(); // validation_failed
$e->getParam(); // to
} catch (RateLimitException $e) {
$e->getRetryAfter(); // seconds
} catch (SendKuyException $e) {
$e->getRequestId(); // quote it when you contact support
}
use SendKuy\Exceptions\SignatureVerificationException;
use SendKuy\Webhook;
try {
$event = Webhook::verify(
file_get_contents('php://input'),
$_SERVER['HTTP_X_SENDKUY_SIGNATURE'] ?? '',
getenv('SENDKUY_WEBHOOK_SECRET'),
);
} catch (SignatureVerificationException $e) {
http_response_code(403);
exit;
}
$deliveryId = $_SERVER['HTTP_X_SENDKUY_EVENT_ID'] ?? ''; // the same on every retry: use it to skip duplicates
if ($event['event'] === 'message.received') {
// ...
}
http_response_code(200);
$sendkuy = new SendKuy($key, ['base_url' => 'https://sendkuy.example.com/api/v1']);
$sendkuy = new SendKuy('sk_test_123', ['http_client' => $fakeClient]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.