Effortless Smooth Flawless Streamlined Seamless SMS Integration with Webhook API
Unlock the full potential of your Android phone by converting it into a powerful SMS gateway. Send and receive unlimited messages with ease, all through a simple API integration.
- 3-Day Free Trial
- No Credit Card
- Cancel Anytime
WebHook Example Script
Include following code in your PHP file to start sending messages.
You can get the API key from your : Account interface.
📄
define("API_KEY", "Your API KEY");
try {
if (isset($_SERVER["HTTP_X_SG_SIGNATURE"])) {
if (isset($_POST["messages"])) {
$hash = base64_encode(hash_hmac('sha256', $_POST["messages"], API_KEY, true));
if ($hash === $_SERVER["HTTP_X_SG_SIGNATURE"]) {
$messages = json_decode($_POST["messages"], true);
/**
* For example :-
* $messages = [
* 0 => [
* "ID" => "1",
* "number" => "+11234567890",
* "message" => "This is a test message.",
* "deviceID" => "1",
* "simSlot" => "0",
* "userID" => "1",
* "status" => "Received",
* "sentDate" => "2018-10-20T00:00:00+02:00",
* "deliveredDate" => "2018-10-20T00:00:00+02:00"
* "groupID" => null
* ]
* ]
*
* senDate represents the date and time when the message was received on the device.
* deliveredDate represents the date and time when the message was received by the server.
*/
foreach ($messages as $message) {
if(strtolower($message["message"]) === "hi") {
// Reply to message using API or execute some commands. Possibilities are limitless.
}
}
} else {
throw new Exception("Signature don't match!");
}
} else if (isset($_POST["ussdRequest"])) {
$hash = base64_encode(hash_hmac('sha256', $_POST["ussdRequest"], API_KEY, true));
if ($hash === $_SERVER["HTTP_X_SG_SIGNATURE"]) {
$ussdRequest = json_decode($_POST["ussdRequest"]);
$deviceID = $ussdRequest->deviceID;
$simSlot = $ussdRequest->simSlot;
$request = $ussdRequest->request;
$response = $ussdRequest->response;
// Do whatever you want with data you received.
} else {
throw new Exception("Signature don't match!");
}
}
} else {
http_response_code(400);
error_log("Signature not found!");
}
} catch (Exception $e) {
http_response_code(401);
error_log($e->getMessage());
}