【问题标题】:Android use a SMS GatewayAndroid 使用短信网关
【发布时间】:2012-06-25 17:09:00
【问题描述】:

我需要在我的安卓应用程序中放入一个工具,该工具使用免费服务通过互联网发送免费短信......

我看到许多应用程序都能够集成这些服务.. 我尝试了很多,但我没有发现任何有用的东西..

所以我问你......我如何使用uthsms.net 的网关(例如)通过我的 Android 应用程序发送短信?

抱歉,这个问题很笼统。但我没有找到任何解决这个问题的起点。

提前致谢

【问题讨论】:

  • 我有同样的要求,你能帮帮我吗

标签: java android sms sms-gateway


【解决方案1】:

使用 Firebug 等工具查看单击网站上的按钮时发送的内容。我看到使用一些参数对 uthsms.net 进行了 POST-Request。您应该能够对您的应用执行相同的 POST。

这些是参数:

button: Send SMS
country: (some integer)
gateway: 0
hyderabad: your message
remLen: remaining length??
sindh: number to send sms to (without the +)
x: some integer
y: some integer

要在 Android 中发送此 POST 请求,请使用以下代码:

URL url = new URL("http://uthsms.net");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();

String data = URLEncoder.encode("button", "UTF-8") + "="
        + URLEncoder.encode("Send SMS", "UTF-8");
data += "&" + URLEncoder.encode("country", "UTF-8") + "="
        + URLEncoder.encode(country, "UTF-8");
data += "&" + URLEncoder.encode("gateway", "UTF-8") + "="
        + URLEncoder.encode("0", "UTF-8");
data += "&" + URLEncoder.encode("hyderabad", "UTF-8") + "="
        + URLEncoder.encode(message, "UTF-8");
data += "&" + URLEncoder.encode("remLen", "UTF-8") + "="
        + URLEncoder.encode(remLen, "UTF-8");
data += "&" + URLEncoder.encode("sindh", "UTF-8") + "="
        + URLEncoder.encode(number, "UTF-8");
data += "&" + URLEncoder.encode("x", "UTF-8") + "="
        + URLEncoder.encode("0", "UTF-8");
data += "&" + URLEncoder.encode("y", "UTF-8") + "="
        + URLEncoder.encode("0", "UTF-8");
conn.setDoOutput(true);

OutputStreamWriter wr = new OutputStreamWriter(
        conn.getOutputStream());
wr.write(data);
wr.flush();


BufferedReader inStream = new BufferedReader(new InputStreamReader((conn.getInputStream())));

result = inStream.readLine();

inStream.close();

结果似乎是一个 html 文档。您应该在里面的某个地方找到成功消息或可能的错误。

【讨论】:

  • 嗨 D-32...recaptcha_challenge_field 和 recaptcha_response_field 怎么样....如果我们将它们留空,消息会被发送吗?
  • 当我写下那个答案时,没有recaptcha 字段。可能他们添加了它以防止这种使用。
【解决方案2】:

试试GoogleVoice API。它有文档,可以帮助您入门。

这是一个链接:https://code.google.com/p/google-voice-java/

【讨论】:

  • 我不认为这是他想要的,这不允许发送“通过互联网免费短信”。它只是让你用声音来做。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多