Tutorials
SENDING SMS
This method provides a way to send the message (SMS) via XML using account details.
These are the standard request parameters that are needed when using the EgoSms XML Api
Contains the user information.
Contains the message information.
The account username.
The account password.
The phone number the message is being sent to.
This represents the message you are sending out. The message source must have a maximum of 160 characters.
This represents who the message is coming from. Sender can have a maximum of 11 characters.
This represents level of priority. Priority can have values from (0-4) with 0: highest, 1: high, 2: Medium, 3: Low, 4: Lowest
SendSms
Egotest
xxxxx
256788200915
welcome to Egosms
Egosms
1
SendSms
Egotest
xxxxx
256788200915
First message
test
0
256788200915
Second message
test
0
256707811116
Third message
test
0
256702662127
Forth message
test
0
OK
---
---
Failed
---
Occurs when there is a syntax error in your XML code.
Occurs if there are insuffient funds of your Egosms Account
Occurs if either your username or password is wrong
Occurs if the account being used does not exist or is inactive
Occurs if either the password or username is empty
$xml_builder = '''
SendSms
Egotest
xxxxx
256702662127
test mtn
test
0
''';
//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;
?>
import requests
# The XML data
xml_builder = '''
SendSms
Egotest
xxxxx
256702662127
test mtn
test
'''
# The API URL
url = 'https://www.egosms.co/api/v1/xml/'
# Set the headers
headers = {
'Content-Type': 'text/xml',
}
# Make the request
response = requests.post(url, headers=headers, data=xml_builder)
# Extract the response body
response_body = response.text
print(response_body)
package xml;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
public class SendXml {
public static void main(String [] args) {
try {
//Setting up the connection
URL url = new URL("https://www.egosms.co/api/v1/xml/");
URLConnection con = url.openConnection();
HttpURLConnection http = (HttpURLConnection)con;
http.setRequestMethod("POST");
http.setDoOutput(true);
//Details to be sent
String username = "EgosmsTest";
String password = "egotest";
String message = "My first message through Egosms";
String number = "256788200915";
String senderid = "Egosms";
//Creating XML format of the details above
byte[] out = ("\n" +
"\n" +
" SendSms \n" +
" \n" +
" "+username+" \n" +
" "+password+" \n" +
" \n" +
" \n" +
" "+number+" \n" +
" "+message+" \n" +
" "+senderid+" \n" +
" \n" +
" ").getBytes(StandardCharsets.UTF_8);
int length = out.length;
//Sending the details through established connection
http.setFixedLengthStreamingMode(length);
http.setRequestProperty("Content-Type", "application/xml; charset=UTF-8");
http.connect();
try(OutputStream os = http.getOutputStream()) {
os.write(out);
}
//Receiving response
BufferedReader in = new BufferedReader(new InputStreamReader(http.getInputStream()));
String line = null;
while((line = in.readLine()) != null) {
System.out.println(line);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
require 'net/http'
require 'uri'
# The XML data
xml_builder = '
SendSms
Egotest
xxxxx
256702662127
test mtn
test
0
'
# 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
#!/bin/bash
# The XML data
xml_builder='
SendSms
Egotest
xxxxx
256702662127
test mtn
test
0
'
# The API URL
url="https://www.egosms.co/api/v1/xml/"
# Make the cURL request
curl -X POST -H "Content-Type: text/xml" -d "$xml_builder" "$url"
SendSms
Egotest
xxxxx
256702662127
test mtn
test
0
$xml_builder = '''
SendSms
Egotest
xxxxx
256702662127
test mtn
test
0
''';
//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;
?>
import requests
# The XML data
xml_builder = '''
SendSms
Egotest
xxxxx
256702662127
test mtn
test
'''
# The API URL
url = 'https://www.egosms.co/api/v1/xml/'
# Set the headers
headers = {
'Content-Type': 'text/xml',
}
# Make the request
response = requests.post(url, headers=headers, data=xml_builder)
# Extract the response body
response_body = response.text
print(response_body)
package xml;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
public class SendXml {
public static void main(String [] args) {
try {
//Setting up the connection
URL url = new URL("https://www.egosms.co/api/v1/xml/");
URLConnection con = url.openConnection();
HttpURLConnection http = (HttpURLConnection)con;
http.setRequestMethod("POST");
http.setDoOutput(true);
//Details to be sent
String username = "EgosmsTest";
String password = "egotest";
String message = "My first message through Egosms";
String number = "256788200915";
String senderid = "Egosms";
//Creating XML format of the details above
byte[] out = ("\n" +
"\n" +
" SendSms\n" +
" \n" +
" "+username+"\n" +
" "+password+"\n" +
" \n" +
" \n" +
" "+number+"\n" +
" "+message+"\n" +
" "+senderid+"\n" +
" \n" +
"").getBytes(StandardCharsets.UTF_8);
int length = out.length;
//Sending the details through established connection
http.setFixedLengthStreamingMode(length);
http.setRequestProperty("Content-Type", "application/xml; charset=UTF-8");
http.connect();
try(OutputStream os = http.getOutputStream()) {
os.write(out);
}
//Receiving response
BufferedReader in = new BufferedReader(new InputStreamReader(http.getInputStream()));
String line = null;
while((line = in.readLine()) != null) {
System.out.println(line);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
require 'net/http'
require 'uri'
# The XML data
xml_builder = '
SendSms
Egotest
xxxxx
256702662127
test mtn
test
0
'
# 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
#!/bin/bash
# The XML data
xml_builder='
SendSms
Egotest
xxxxx
256702662127
test mtn
test
0
'
# The API URL
url="https://www.egosms.co/api/v1/xml/"
# Make the cURL request
curl -X POST -H "Content-Type: text/xml" -d "$xml_builder" "$url"
SendSms
Egotest
xxxxx
256702662127
test mtn
test
0
$xml_builder = '''
SendSms
Egotest
xxxxx
256702662127
test mtn
test
0
''';
//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;
?>
import requests
# The XML data
xml_builder = '''
SendSms
Egotest
xxxxx
256702662127
test mtn
test
'''
# The API URL
url = 'https://www.egosms.co/api/v1/xml/'
# Set the headers
headers = {
'Content-Type': 'text/xml',
}
# Make the request
response = requests.post(url, headers=headers, data=xml_builder)
# Extract the response body
response_body = response.text
print(response_body)
#!/bin/bash
# The XML data
xml_builder='
SendSms
Egotest
xxxxx
256702662127
test mtn
test
0
'
# The API URL
url="https://www.egosms.co/api/v1/xml/"
# Make the cURL request
curl -X POST -H "Content-Type: text/xml" -d "$xml_builder" "$url"
require 'net/http'
require 'uri'
# The XML data
xml_builder = '
SendSms
Egotest
xxxxx
256702662127
test mtn
test
0
'
# 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
SendSms
Egotest
xxxxx
256702662127
test mtn
test
0
Egosms Documentation
Tutorials
SENDING SMS