Tutorials
SENDING SMS
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:
LIVE URL:https://www.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 API callers password used to login to Egosms.
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 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.
# 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")
package http;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.StringJoiner;
public class SendHttp {
public static void main(String[] args) {
try {
//Parameters to add to the URL
LinkedHashMap params = new LinkedHashMap<>();
params.put("number", "256788200915");
params.put("message", "My first message through Egosms");
params.put("username", "EgosmsTest");
params.put("password", "egotest");
params.put("sender", "Egosms");
StringJoiner sj = new StringJoiner("&");
//Encoding the above parameters
for(Map.Entry entry : params.entrySet())
sj.add(URLEncoder.encode(entry.getKey(), "UTF-8") + "="
+ URLEncoder.encode(entry.getValue(), "UTF-8"));
String encoded_params = sj.toString();
//URL with necessary parameters added
String urlParams = "https://www.egosms.co/api/v1/plain/?"+encoded_params;
//Sending Http request to above composed URL
URL url = new URL(urlParams);
URLConnection con = url.openConnection();
HttpURLConnection http = (HttpURLConnection)con;
http.setRequestMethod("GET");
http.setDoOutput(true);
http.setRequestProperty("Content-Type", "text/plain; charset=UTF-8");
//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();
}
}
}
Tutorials
SENDING SMS