Hi, I have configured the Traccar SMS Gateway and configured Traccar to work accordingly.
I want to use the Traccar SMS Gateway and its API to my custom applications also. Its supper cheap than Bulk SMS provider.
is this possible to do with Traccar SMS Gateway? This would be such a nice thing for me if this is possible.
Below is my sample code.
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$phone = $_POST['phone'];
$message = $_POST['message'];
$apiUrl = "http://**.130.195.223:8082/sms";
$authorizationToken = "*******************************************";
$data = [
"to" => $phone,
"message" => $message,
"token"=>$authorizationToken
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
if (curl_errno($ch)) {
$error = "Error: " . curl_error($ch);
} else {
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$result = "Status Code: $httpCode<br>Response: $response";
}
curl_close($ch);
}
?>
Is there any Api documentation for this? I couldn't find it anywhere
Hi, I have configured the Traccar SMS Gateway and configured Traccar to work accordingly.
I want to use the Traccar SMS Gateway and its API to my custom applications also. Its supper cheap than Bulk SMS provider.
is this possible to do with Traccar SMS Gateway? This would be such a nice thing for me if this is possible.
Below is my sample code.
<?php if ($_SERVER["REQUEST_METHOD"] == "POST") { // Retrieve input from the form $phone = $_POST['phone']; $message = $_POST['message']; // API URL and Authorization Token $apiUrl = "http://**.130.195.223:8082/sms"; $authorizationToken = "*******************************************"; // Data payload using the template $data = [ "to" => $phone, "message" => $message, "token"=>$authorizationToken ]; // Initialize cURL $ch = curl_init(); // Set cURL options curl_setopt($ch, CURLOPT_URL, $apiUrl); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json' ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); // Execute the request $response = curl_exec($ch); // Handle errors or display response if (curl_errno($ch)) { $error = "Error: " . curl_error($ch); } else { $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $result = "Status Code: $httpCode<br>Response: $response"; } // Close cURL session curl_close($ch); } ?>