Tutorials

SENDING SMS

SENDING SMS

Using XML

Overview

This method provides a way to send the message (SMS) via XML using account details.

Send SMS through your application by making an HTTP POST request to the following endpoints:

XML Request Parameters

These are the standard request parameters that are needed when using the EgoSms XML Api

userdataString Required

Contains the user information.

msgdataString Required

Contains the message information.

usernameString Required

The account username.

passwordString Required

The account password.

numberString Required

The phone number the message is being sent to.

messageString Required

This represents the message you are sending out. The message source must have a maximum of 160 characters.

senderidString Required

This represents who the message is coming from. Sender can have a maximum of 11 characters.

priorityString Optional

This represents level of priority. Priority can have values from (0-4) with  0: highest, 1: high, 2: Medium, 3: Low, 4: Lowest

Example

Example for sending a single message.

				
					<?xml version="1.0" encoding="UTF-8"?>
<Request>
   <method>SendSms</method>
   <userdata>
      <username>Egotest</username>
      <password>xxxxx</password>
   </userdata>
   <msgdata>
      <number>256788200915</number>
      <message>welcome to Egosms</message>
      <senderid>Egosms</senderid>
      <priority>1</priority>
   </msgdata>
</Request>
				
			

Example for sending multiple messages.

				
					<?xml version="1.0" encoding="UTF-8"?>
<Request>
   <method>SendSms</method>
   <userdata>
      <username>Egotest</username>
      <password>xxxxx</password>
   </userdata>
   <msgdata>
      <number>256788200915</number>
      <message>First message</message>
      <senderid>test</senderid>
      <priority>0</priority>
   </msgdata>
   <msgdata>
      <number>256788200915</number>
      <message>Second message</message>
      <senderid>test</senderid>
      <priority>0</priority>
   </msgdata>
   <msgdata>
      <number>256707811116</number>
      <message>Third message</message>
      <senderid>test</senderid>
      <priority>0</priority>
   </msgdata>
   <msgdata>
      <number>256702662127</number>
      <message>Forth message</message>
      <senderid>test</senderid>
      <priority>0</priority>
   </msgdata>
</Request>
				
			

System Feedback

On Success

Once your message has been successfully submitted to the EgoSms system, it will return xml in the format shown below:
				
					<?xml version="1.0" encoding="UTF-8"?>
<Response>
   <Status>OK</Status>
   <Cost>---</Cost>
   <MsgFollowUpUniqueCode>---</MsgFollowUpUniqueCode>
</Response>
				
			

On Failure

Once your message fails to be submitted to the EgoSms system, it will return xml in the format shown below:
				
					<?xml version="1.0" encoding="UTF-8"?>
<Response>
   <Status>Failed</Status>
   <Message>---</Message>
</Response>
				
			

Possible Error messages

Error

Meaning

Add Your Heading Text Here

Occurs when there is a syntax error in your XML code.

Money Not Enough To Send This Batch of Msgs

Occurs if there are insuffient funds of your Egosms Account

Wrong Username or Password

Occurs if either your username or password is wrong

That user does not exist or user not active

Occurs if the account being used does not exist or is inactive

Either Username or Password Not Set

Occurs if either the password or username is empty

Programming Example

				
					$xml_builder = '''
    <?xml version="1.0" encoding="UTF-8"?>
<Request> 
    <method>SendSms</method>
    <userdata> 
        <username>Egotest</username>
        <password>xxxxx</password>
    </userdata>
    <msgdata>
        <number>256702662127</number> 
        <message>test mtn</message> 
        <senderid>test</senderid>
        <priority>0</priority>
    </msgdata> 
</Request>
''';
    
    //use curl to post the xml information
    
    $ch = curl_init('https://www.egosms.co/api/v1/xml/');
    
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: text/xml'
    ));
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_builder);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $ch_result = curl_exec($ch);
    curl_close($ch);
    echo $ch_result;
?>

				
			
				
					require 'net/http'
require 'uri'

# The XML data
xml_builder = '
    <?xml version="1.0" encoding="UTF-8"?>
    <Request>
        <method>SendSms</method>
        <userdata>
            <username>Egotest</username>
            <password>xxxxx</password>
        </userdata>
        <msgdata>
             <number>256702662127</number>
             <message>test mtn</message>
             <senderid>test</senderid>
             <priority>0</priority>
        </msgdata>
    </Request>'

# The API URL
url = URI.parse("https://www.egosms.co/api/v1/xml/")

# Create the HTTP object
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

# Create the request
request = Net::HTTP::Post.new(url.path)
request.body = xml_builder
request.add_field('Content-Type', 'text/xml')

# Make the request
response = http.request(request)

# Extract the response body
response_body = response.body

puts response_body

				
			
				
					$xml_builder = '''
    <?xml version="1.0" encoding="UTF-8"?>
<Request> 
    <method>SendSms</method>
    <userdata> 
        <username>Egotest</username>
        <password>xxxxx</password>
    </userdata>
    <msgdata>
        <number>256702662127</number> 
        <message>test mtn</message> 
        <senderid>test</senderid>
        <priority>0</priority>
    </msgdata> 
</Request>
''';
    
    //use curl to post the xml information
    
    $ch = curl_init('https://www.egosms.co/api/v1/xml/');
    
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: text/xml'
    ));
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_builder);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $ch_result = curl_exec($ch);
    curl_close($ch);
    echo $ch_result;
?>