You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello there, I am trying to send a SMS with Java. I haven't quite understood if I have to put the prefix in front of the number I am trying to send or not.
Anyhow, here's the code I'm using:
URL url = new URL("http://textbelt.com/intl");
Map<String,Object> params = new LinkedHashMap<>();
params.put("number", "+39*******");
params.put("message", "hithere");
StringBuilder postData = new StringBuilder();
for (Map.Entry<String,Object> param : params.entrySet()) {
if (postData.length() != 0) postData.append('&');
postData.append(URLEncoder.encode(param.getKey(), "UTF-8"));
postData.append('=');
postData.append(URLEncoder.encode(String.valueOf(param.getValue()), "UTF-8"));
}
byte[] postDataBytes = postData.toString().getBytes("UTF-8");
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
conn.setDoOutput(true);
conn.getOutputStream().write(postDataBytes);
Reader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
for ( int c = in.read(); c != -1; c = in.read() )
System.out.print((char)c);
}
And I'm getting as response:
{
"success": true
}
Both with and without prefix. Yet no message is arriving to my phone. My carrier is TIM (which is listed as supported)
The text was updated successfully, but these errors were encountered:
Hello there, I am trying to send a SMS with Java. I haven't quite understood if I have to put the prefix in front of the number I am trying to send or not.
Anyhow, here's the code I'm using:
And I'm getting as response:
Both with and without prefix. Yet no message is arriving to my phone. My carrier is TIM (which is listed as supported)
The text was updated successfully, but these errors were encountered: