Send
Send an SMS message through the SendMode API.
Available HTTP Methods: POST
Parameters
Parameter | Type | Description | Required |
---|---|---|---|
message | string | JSON string with the variables to send a SMS. | Yes |
Message JSON
Parameter | Type | Description | Required |
---|---|---|---|
messagetext | string | The content of the SMS message. | Yes |
recipients | array | An array of mobile numbers to receive the message. | Yes |
senderid | string | The sender id displayed on the recipients device. | No |
customerid | string | A reference id for your message. | No |
scheduledate | string | Date and time to schedule your message to be sent to nearest 15 minute interval. NOTE:Must be valid datetime format. | No |
Example Message JSON
{ "messagetext":"Hello World", "senderid":"Sendmode", "recipients":["0870000000"] }
Code Examples
C#
using (WebClient client = new WebClient()) { client.Headers.Add("Authorization", "YOUR_ACCESS_KEY"); string[] recipients = new string[1]; recipients[0] = "0870000000 string message = "Hello World"; var postJson = new JavaScriptSerializer().Serialize(new { messagetext = message, senderid = "Sendmode", recipients = recipients }); byte[] response = client.UploadValues("https://rest.sendmode.com/v2/send", new NameValueCollection() { { "message", postJson } }); string result = System.Text.Encoding.UTF8.GetString(response); }
php
$arr = array('messagetext' => 'This is a test', 'senderid' => 'SendMode', 'recipients' => array('0870000000')); $url = 'https://rest.sendmode.com/v2/send'; $data = array('message' => json_encode($arr)); // use key 'http' even if you send the request to https://... $options = array( 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded\r\n" . "Authorization: YOUR_ACCESS_KEY\r\n", 'method' => 'POST', 'content' => http_build_query($data) ) ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context);
Java
HttpClient httpclient = HttpClients.createDefault(); HttpPost httppost = new HttpPost("https://rest.sendmode.com/v2/send"); httppost.setHeader(HttpHeaders.AUTHORIZATION, YOUR_ACCESS_KEY); String json = "{\"messagetext\" : \"Hello World\", \"recipients\" : [\"0870000000\"]}"; List<NameValuePair> params = new ArrayList<NameValuePair>(1); params.add(new BasicNameValuePair("message", json)); httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity();
Response
{ "status":"OK", "statusCode":0, "acceptedDateTime":"2017-08-25T12:51:01.1808223+01:00", "message":{ "senderid":"Sendmode", "messagetext":"Hello World", "customerid":null, "scheduledate":null, "recipients":["0870000000"] } }