Tutorials

SENDING SMS

DELIVERY REPORT

Overview

This method provides a way to receive Egosms Transaction Status delivery report via JSON 

Requirement 

  1. Delivery Report URL  

Procedure  

In your application, create a path (DLR URL) to listen and capture json data as below; 

{“MsgFollowUpUniqueCode”: “ApiJsonSubmit64b8dd8aab0d05.55176607″,”number”: “+256777071434″,”Status”: “Success”} 

Capturing DLR URL Code Example 

				
					<?php 
    $data=file_get_contents("php://input"); 
    
    file_put_contents(msg_details.txt',$data,FILE_APPEND); 
    
    echo “ok, msg delivered”; 
?>
				
			

Copy the file path as the DLR_URL  

DLR_URL example 

https://xxxx/capture.php  

Setting up Egosms Account to receive transaction status delivery report 

Steps 

  1. Log into your account . 
  2. Click edit profile.  
  3. Paste the DLR URL: eg https://xxxx/capture.php in the DLR URL field.

Everything is now set up.

How To Use

Log into your system and send a message. 

System Feedback 

The Following Transaction Status Report including status, cost and MsgFollowUpUniqueCode will be received

SMS Delivered report

				
					{"MsgFollowUpUniqueCode": "ApiJsonSubmit64b8dd8aab0d05.55176607","number": "+256777071434","Status": "Success"} 
				
			

Saving SMS Delivered report into the database code PHP Example

				
					<?php 

// Assuming you have the necessary credentials to connect to your MySQL database 
$servername = "xxxxxx"; 
$username = "xxxxxxx"; 
$password = "******"; 
$dbname = "xxxxxxx"; 
// Create a connection to the database 
$conn = new mysqli($servername, $username, $password, $dbname); 
// Check the connection 
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error); 
} 
// Read the raw data from the incoming HTTP request's body 
$data = file_get_contents("php://input"); 
// Decode the JSON data into an associative array 
$decoded_data = json_decode($data, true); 
//put data to the msgdata.txt 
file_put_contents('msgdata.txt', $data, FILE_APPEND); 
// Check if JSON decoding was successful 
if ($decoded_data === null) { 
    echo "Error decoding JSON data."; 
    exit; 
} 
// Extract data from the new JSON structure 
$number = $decoded_data['number']; 
$message_code = $decoded_data['MsgFollowUpUniqueCode']; 
$status = $decoded_data['Status']; 
// Escape each value to prevent SQL injection 
$number = $conn->real_escape_string($number); 
$message_code = $conn->real_escape_string($message_code); 
$status = $conn->real_escape_string($status); 

// SQL query to insert the data into a table named 'egosmsdata' 
$sql = "INSERT INTO tableName (number, message_code, status) VALUES ('$number', '$message_code', '$status')"; 
if ($conn->query($sql) !== TRUE) { 
    echo "Error in saving delivery report: " . $conn->error; 
    $conn->close(); 
    exit; 
} 
echo "Delivery report saved successfully into the database."; 

// Close the database connection 
$conn->close(); 
?> 
				
			

Capturing DLR URL Code Examples

				
					$data=file_get_contents("php://input"); 

file_put_contents(msg_details.txt',$data,FILE_APPEND); 

echo “ok, msg delivered”;