Send
Send an SMS message through the SendMode HTTP API.
Available HTTP Methods: GET
Parameters
Parameter | Description | Mandatory |
---|---|---|
type | sendparam | Yes |
username | account username | Yes |
password | account password | Yes |
senderid | The sender id displayed on the recipients device. | Yes |
numto | The mobile number to receive the message. | Yes |
data1 | The content of the SMS message. | Yes |
customerid | A 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
C#
C# Code Example - Sending SMS using System; using System.Net.Http; using System.Threading.Tasks; public class SMSClient { private static readonly HttpClient client = new HttpClient(); public static async Task<string> SendSMS(string username, string password, string senderId, string recipient, string message) { string url = $"https://api.sendmode.com/httppost.aspx?username={username}&password={password}&senderid={senderId}&numto={recipient}&data1={Uri.EscapeDataString(message)}"; HttpResponseMessage response = await client.GetAsync(url); return await response.Content.ReadAsStringAsync(); } public static async Task Main(string[] args) { string response = await SendSMS("your_username", "your_password", "your_senderid", "recipient_number", "your_message_content"); Console.WriteLine(response); } }
PHP
PHP Code Example - Sending SMS <?php function SendSMS($username, $password, $senderId, $recipient, $message) { $url = 'https://api.sendmode.com/httppost.aspx?' . http_build_query([ 'username' => $username, 'password' => $password, 'senderid' => $senderId, 'numto' => $recipient, 'data1' => $message ]); $response = file_get_contents($url); return $response; } // Example usage $response = SendSMS('your_username', 'your_password', 'your_senderid', 'recipient_number', 'your_message_content'); echo $response; ?>
Python
PYTHON Code Example - Sending SMS import requests def send_sms(username, password, sender_id, recipient, message): url = 'https://api.sendmode.com/httppost.aspx' params = { 'username': username, 'password': password, 'senderid': sender_id, 'numto': recipient, 'data1': message } response = requests.get(url, params=params) return response.text # Example usage response = send_sms('your_username', 'your_password', 'your_senderid', 'recipient_number', 'your_message_content') print(response)
Java
JAVA Code Example - Sending SMS import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLEncoder; public class SMSClient { public static String sendSMS(String username, String password, String senderId, String recipient, String message) { try { String urlStr = String.format( "https://api.sendmode.com/httppost.aspx?username=%s&password=%s&senderid=%s&numto=%s&data1=%s", URLEncoder.encode(username, "UTF-8"), URLEncoder.encode(password, "UTF-8"), URLEncoder.encode(senderId, "UTF-8"), URLEncoder.encode(recipient, "UTF-8"), URLEncoder.encode(message, "UTF-8") ); URL url = new URL(urlStr); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); StringBuilder response = new StringBuilder(); String inputLine; while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); conn.disconnect(); return response.toString(); } catch (Exception e) { e.printStackTrace(); return "Error sending SMS: " + e.getMessage(); } } public static void main(String[] args) { String response = sendSMS("your_username", "your_password", "your_senderid", "recipient_number", "your_message_content"); System.out.println(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>