Import JSON
{
"mobilenumber":"0870000000",
"firstname":"Hello",
"surname":"World"
}
{
"mobilenumber":"0870000000",
"firstname":"Hello",
"surname":"World"
}
{
"status":"EXPECTED_PARAMETER_MISSING",
"statusCode":195,
"error":"You do not have all the required variables in your [message] data"
}
{
"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"]
}
}
{
"status":"OK",
"statusCode":0,
"balance":7502.4400
}
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();
$response = file_get_contents("http://rest.sendmode.com/v2/credits?access_key=YOUR_ACCESS_KEY");
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);
}
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();
$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);
{
"messagetext":"Hello World",
"senderid":"Sendmode",
"recipients":["0870000000"]
}