Send

Send an SMS message through the SendMode HTTP API.

Available HTTP Methods: GET

sm_api_icon

Parameters

Parameters

ParameterDescriptionMandatory
typesendparamYes
usernameaccount usernameYes
passwordaccount passwordYes
senderidThe sender id displayed on the recipients device. Yes
numtoThe mobile number to receive the message.Yes
data1The content of the SMS message.Yes
customeridA reference id for your message.No
Example Message JSON
[
https://api.sendmode.com/httppost.aspx?Type=sendparam&username=xxx&password=yyy&numto=1234567890&data1=mytestmsg
Code Examples

Code Examples

C#
 C# Code Example - Sending SMS

<%@ Import Namespace=”System.Net”%>
<%@ Import Namespace=”System.IO”%>
<%@ Import Namespace=”System.Web”%>
<script language=”C#” runat=”server”>

void Page_Load(Object Src, EventArgs E) {
myPage.Text = readHtmlPage(“https://api.sendmode.com/httppost.aspx”);
}
private String readHtmlPage(string url)
{
String result = “”;
String message = HttpUtility.UrlEncode(“Hello world!”);
String strPost = “username=yourusername&password=yourpass&data1=” + message + “&numto=44712345678″
strPost += “&senderid=TEST&type=sendparam”;
StreamWriter myWriter = null;

HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
objRequest.ContentLength = Encoding.UTF8.GetByteCount(strPost);
objRequest.ContentType = “application/x-www-form-urlencoded”;
try{
myWriter = new StreamWriter(objRequest.GetRequestStream());
myWriter.Write(strPost);
}
catch (Exception e)
{
return e.Message;
}
finally {
myWriter.Close();
}

HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()) )
{
result = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
return result;
}
</>
php
PHP Code Example - Sending SMS

<?php

$sms_username = "yourusername";
$sms_password = "yourpassword";
$mobilenumber = "353871234567";
$message = "Hello this is testing Sendmode gateway";
$senderid = "TEST";
  
$url = "https://api.sendmode.com/httppost.aspx?Type=sendparam&username=".urlencode($sms_username)."&password=".urlencode($sms_password)."&numto=".urlencode($mobilenumber)."&data1=".urlencode($message)."&senderid=".urlencode($senderid);
  //pr($url) ; die;
$reply = file_get_contents($url);
$reply_data = simplexml_load_string($reply);
$val=$reply_data->call_result->result;
echo $val;
?>
Java
JAVA Code Example - Sending SMS

 

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;

public class SMSSender {

public String sendSms(String sToPhoneNo,String sMessage) {
try {
// Construct data
String data = “username=” + URLEncoder.encode(“username****”, “UTF-8″);
data += “& password =” + URLEncoder.encode(“password****”, “UTF-8″);
data += “&numto=” + URLEncoder.encode(sToPhoneNo, “UTF-8″);
data += “&data1=” + URLEncoder.encode(sMessage, “UTF-8″);
data += “&senderid=” + URLEncoder.encode(“senderid”, “UTF-8″);
data += “&type=” + URLEncoder.encode(“sendparam”, “UTF-8″);

// Send data
URL url = new URL(“https://api.sendmode.com/httppost.aspx”);
URLConnection conn = url.openConnection();
conn.setDoOutput(true);

OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();

// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
String sResult=”";
while ((line = rd.readLine()) != null) {
// Process line…
sResult=sResult+line+” “;
}
wr.close();
rd.close();
return sResult;
} catch (Exception e) {
System.out.println(“Error SMS “+e);
return “Error “+e;
}
Response

Response


The output of the following will be defined by the input of the above parameters:

<httppost_result>

    <call_result>

        <result>True</result>

        <error></error> 

    </call_result> 

</httppost_result>