再次发布FreeSMS!
我正在使用http://www.freesmsgateway.com/api通过Java在移动设备上发送短信。
我已经在给定的门户网站上注册,我得到了api-key。使用这个api-key,当我运行Java代码时,我得到以下响应 -
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<h4>A PHP Error was encountered</h4>
<p>Severity: Notice</p>
<p>Message: Trying to get property of non-object</p>
<p>Filename: controllers/api_send.php</p>
<p>Line Number: 127</p>
</div>Message sent
但我手机上没有收到任何短信。此外,我试图从他们的网站发送短信,但没有收到任何短信。
我的Java代码 -
HttpPost post = new HttpPost("http://www.FreeSMSGateway.com/api_send");
String access_token = "XXXXXXXXXXXXXXXXXXXXXXXXXX";
String message = "Hello, this is demo message from SMS gateway";
String send_to = "post_contacts";
JSONArray jPostContact = new JSONArray();
jPostContact.put("+91XXXXXXXXXX");
List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
urlParameters.add(new BasicNameValuePair("access_token", access_token));
urlParameters.add(new BasicNameValuePair("message", message));
urlParameters.add(new BasicNameValuePair("send_to", send_to));
urlParameters.add(new BasicNameValuePair("post_contacts", jPostContact.toString()));
post.setEntity(new UrlEncodedFormEntity(urlParameters));
HttpResponse httpResponse = client.execute(post);
请帮我解决此问题。感谢
答案 0 :(得分:0)
将“content-type”设置为“application / json”,您将摆脱此问题