首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Java中没有收到SMS-Gateway发送的SMS?

在Java中没有收到SMS-Gateway发送的SMS?
EN

Stack Overflow用户
提问于 2013-08-02 21:55:00
回答 1查看 1.2K关注 0票数 1

FreeSMS问题又来了!

我正在使用http://www.freesmsgateway.com/api通过Java在手机上发送短信。

我已经在给定的门户上注册了,我得到了api-key。使用此api-key,当我运行Java代码时,我得到以下响应-

代码语言:javascript
复制
<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代码-

代码语言:javascript
复制
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);

请帮我解决这个问题。谢谢

EN

回答 1

Stack Overflow用户

发布于 2013-08-29 06:39:47

将"content-type“设置为"application/json”,就可以解决这个问题

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18018674

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档