This method provides a way to send the message (SMS) via HTTP using account details.
Send SMS through your application by making an HTTP GET request to the following endpoints:
SANDBOX URL: http://sandbox.egosms.co/api/v1/plain/
These are the standard request parameters that are needed when using the HTTP method of the EgoSMS API.
Â
The parameters should be separated using the ‘&’ sign just like in a normal http get.
The API callers username used to login to Egosms.
The URL encoded password to your Ego Sms Account
The phone number the message is being sent to.
This represents the URL encoded SMS 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 and needs to be URL encoded too.
This represents level of priority. Priority can have values from (0-4) with 0: highest, 1: high, 2: Medium, 3: Low, 4: Lowest
The above link will send a message “My first message through Egosms” to the number “256788200915” using and Egosms Account whose username is “EgosmsTest” and password “egotest”
Once your message has been successfully sent to the network the system will show ‘Ok’ otherwise it will show error.
This is returned if either the provided password or username is wrong.
This is if returned any of the fields (username /Â password / number / message / ‘senderid) is empty.
Occurs if there are insuffient funds of your Egosms Account.
Occurs if the account being used does not exist or is inactive or if the username is not set.
function SendSMS($username, $password, $sender, $number, $message)
{
$url = "www.egosms.co/api/v1/plain/?";
$parameters = "number=[number]&message=[message]&username=[username]&password=[password]&sender=[sender]";
$parameters = str_replace("[message]", urlencode($message) , $parameters);
$parameters = str_replace("[sender]", urlencode($sender) , $parameters);
$parameters = str_replace("[number]", urlencode($number) , $parameters);
$parameters = str_replace("[username]", urlencode($username) , $parameters);
$parameters = str_replace("[password]", urlencode($password) , $parameters);
$live_url = "https://" . $url . $parameters;
$parse_url = file($live_url);
$response = $parse_url[0];
return $response;
}
$username = "Egosmstest";
$password = "egotest";
$sender = "Egosms";
$number = "+256788200915";
$message = "My First Message through Egosms";
echo SendSMS($username, $password, $sender, $number, $message);
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void saveMessageToFile(String data, String filename) throws IOException {
try (BufferedWriter writer = new BufferedWriter(new FileWriter(filename, true))) {
writer.write(data + "\n");
}
}
public static void main(String[] args) {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String data = reader.readLine().trim();
reader.close();
if (!data.isEmpty()) { saveMessageToFile(data, "msg_details.txt");
System.out.println("ok, msg delivered");
} else {
System.out.println("Error: No data received.");
}
} catch (IOException e) {
System.out.println("Error: " + e.getMessage());
}
}
}
# importing the requests library
import json
import requests
import html
# The api url
url = "https://www.egosms.co/api/v1/plain/"
# The parameters to be sent to the ego sms api
password = "xxxxxx"
username = "egotest"
sender = "Egosms"
number = "256707811113"
message = "This is a message"
parameters = {
'username': html.escape(username),
'password': html.escape(password),
'number': html.escape(number),
'message': html.escape(message),
'sender': html.escape(sender)
}
timeout = 5
# Check for the internet connection and make the request
try:
# sending post request and saving response as response object
r = requests.get(url=url, params=parameters, timeout=timeout)
# extracting response text
response = r.text
print(response)
except(requests.ConnectionError, requests.Timeout) as exception:
print("Check your internet connection")
require 'net/http'
require 'uri'
def send_sms(username, password, sender, number, message)
url = "www.egosms.co/api/v1/plain/?"
parameters = "number=[number]&message=[message]&username=[username]&password=[password]&sender=[sender]"
parameters = parameters.gsub("[message]", URI.encode_www_form_component(message))
.gsub("[sender]", URI.encode_www_form_component(sender))
.gsub("[number]", URI.encode_www_form_component(number))
.gsub("[username]", URI.encode_www_form_component(username))
.gsub("[password]", URI.encode_www_form_component(password))
live_url = "https://" + url + parameters
uri = URI.parse(live_url)
response = Net::HTTP.get(uri)
return response
end
username = "Egosmstest"
password = "egotest"
sender = "Egosms"
number = "+256788200915"
message = "My First Message through Egosms"
result = send_sms(username, password, sender, number, message)
puts result
import curl
func SendSMS(username string, password string, sender string, number string, message string) string {
url := "https://www.egosms.co/api/v1/plain/"
parameters := "number=" + curl.Escape(number) + "&message=" + curl.Escape(message) + "&username=" + curl.Escape(username) + "&password=" + curl.Escape(password) + "&sender=" + curl.Escape(sender)
liveURL := url + "?" + parameters
c := curl.EasyInit()
defer c.Cleanup()
c.Setopt(curl.OPT_URL, liveURL)
var response string
c.Setopt(curl.OPT_WRITEFUNCTION, func(buf []byte, userdata interface{}) bool {
response = string(buf)
return true
})
err := c.Perform()
if err != nil {
fmt.Println("Error:", err)
}
return response
}
func main() {
username := "Egosmstest"
password := "egotest"
sender := "Egosms"
number := "+256788200915"
message := "My First Message through Egosms"
fmt.Println(SendSMS(username, password, sender, number, message))
}
using System;
using System.IO;
using System.Net;
class Program
{
static string SendSMS(string username, string password, string sender, string number, string message)
{
string url = "www.egosms.co/api/v1/plain/?";
string parameters = "number=[number]&message=[message]&username=[username]&password=[password]&sender=[sender]";
parameters = parameters.Replace("[message]", Uri.EscapeDataString(message));
parameters = parameters.Replace("[sender]", Uri.EscapeDataString(sender));
parameters = parameters.Replace("[number]", Uri.EscapeDataString(number));
parameters = parameters.Replace("[username]", Uri.EscapeDataString(username));
parameters = parameters.Replace("[password]", Uri.EscapeDataString(password));
string liveUrl = "https://" + url + parameters;
using (WebClient client = new WebClient())
{
string response = client.DownloadString(liveUrl);
return response;
}
}
static void Main()
{
string username = "Egosmstest";
string password = "egotest";
string sender = "Egosms";
string number = "+256788200915";
string message = "My First Message through Egosms";
string result = SendSMS(username, password, sender, number, message);
Console.WriteLine(result);
}
}