PHP IMPORT

By
$arr =  array('mobilenumber' => '0870000000', 'firstname' => 'Hello');
$url = 'https://rest.sendmode.com/v2/import';
$data = array('importdata' => 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);

Read more

C# IMPORT

By
string customer = new JavaScriptSerializer().Serialize(new 
    { 
        mobilenumber = "0870000000",
        firstname = "Hello" 
    }
);
string group = "Hello World";

using (WebClient client = new WebClient())
{
    client.Headers.Add("Authorization", "YOUR_ACCESS_KEY");
    byte[] response = client.UploadValues("https://rest.sendmode.com/v2/import", new NameValueCollection()
    {
        { "importdata", customer},
        { "group", group},
    });

    string result = System.Text.Encoding.UTF8.GetString(response);
}

Read more

JSON ERROR

By
{
    "status":"EXPECTED_PARAMETER_MISSING",
    "statusCode":195,
    "error":"You do not have all the required variables in your [message] data"
}

Read more

JSON Send

By
{
    "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"]
    }
    
}

Read more

JAVA CREDITS

By
URL url = new URL("http://rest.sendmode.com/v2/credits?access_key=YOUR_ACCESS_KEY");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");

BufferedReader in = new BufferedReader(
  new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
    content.append(inputLine);
}
in.close();
con.disconnect();

Read more

PHP CREDITS

By
$response = file_get_contents("http://rest.sendmode.com/v2/credits?access_key=YOUR_ACCESS_KEY");

Read more

C# CREDITS

By
string url = string.Format("http://rest.sendmode.com/v2/credits?access_key={0}", "YOUR_ACCESS_KEY");
using (var client = new WebClient())
{
    var responseString = client.DownloadString(url);
}

Read more

Java SEND

By
JAVA Code Example - Sending SMS
 
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;

public class SendmodeClient {

    private static final String API_URL = "https://rest.sendmode.com/v2/send";
    private static final String API_KEY = "YOUR_ACCESS_KEY";

    public static void sendSMS(String senderId, String recipient, String messageText) throws Exception {
        String jsonMessage = String.format(
            "{\"messagetext\":\"%s\",\"senderid\":\"%s\",\"recipients\":[\"%s\"]}",
            messageText, senderId, recipient
        );

        String urlParameters = "message=" + jsonMessage;
        byte[] postData = urlParameters.getBytes(StandardCharsets.UTF_8);

        URL url = new URL(API_URL);
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("POST");
        conn.setRequestProperty("Authorization", API_KEY);
        conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
        conn.setDoOutput(true);

        try (OutputStream os = conn.getOutputStream()) {
            os.write(postData);
        }

        int responseCode = conn.getResponseCode();
        System.out.println("Response Code: " + responseCode);
    }

    public static void main(String[] args) {
        try {
            sendSMS("your_senderid", "recipient_number", "your_message_content");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Read more