Java 发送和接收短信。免费短信网关?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4178437/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 12:23:05  来源:igfitidea点击:

Java send and receive SMS. Free SMS gateway?

javasmsgateway

提问by vale4674

On some questions here on SOverflow I found THIS. But it says that it is not avaiable at the moment and probably it will never get avaiable.

在 SOverflow 上的一些问题上,我发现了THIS。但它说它目前不可用,可能永远不会可用。

Based on THISI realised that there is no need on building my own SMS service.

基于此,我意识到无需构建自己的 SMS 服务。

So the question:

所以问题是:

My java application has to send SMS messages to users and receive SMS messages from users. Do I really need to pay some SMS gateway or is there some free SMS GATEWAY (with some limitations ofcourse) that I could use to test my application?

我的 java 应用程序必须向用户发送 SMS 消息并接收来自用户的 SMS 消息。我真的需要支付一些 SMS 网关,还是有一些免费的 SMS GATEWAY(当然有一些限制)可以用来测试我的应用程序?

Simplewire Kitlooks really simple but the demo examples are failing because I don' have Simplewire account. Simplewire documentation says that there is a 30-day trial for sending SMS. But this is for two way:

Simplewire Kit看起来非常简单,但是演示示例失败了,因为我没有Simplewire 帐户。Simplewire 文档说发送短信有 30 天的试用期。但这是两种方式:

"For 2-Way, demo credits are not available because you will need your own mobile number hosted on Simplewire's Network. Simplewire supports 2-Way numbers for many different countries and area codes. Please contact Simplewire for more information."

“对于 2-Way,演示积分不可用,因为您需要在 Simplewire 的网络上托管自己的手机号码。Simplewire 支持许多不同国家和区号的 2-Way 号码。请联系 Simplewire 了解更多信息。”

采纳答案by Phill Pafford

FYI Simplewire is now OpenMarket.com/MXTelecom.com

仅供参考 Simplewire 现在是 OpenMarket.com/MXTelecom.com

There are a couple of free SMS gateways but they all attach a SMS ad in your message to pay for the cost. ZeepMobile is the one I hear about the most. As for paying there are a couple of solution but this all depends on your needs.

有几个免费的 SMS 网关,但它们都在您的消息中附加了 SMS 广告以支付费用。ZeepMobile 是我听到最多的一个。至于付款,有几种解决方案,但这一切都取决于您的需求。

Two way communication would require the end user to subscribe to your service. There are a few ways to approach this:

双向通信需要最终用户订阅您的服务。有几种方法可以解决这个问题:

Short Code: you could get your own (www.openmarket.com) or share with others (www.clickatell.com) You could use a new service www.twilio.com looks to be good but haven't tested it yet.

短代码:您可以拥有自己的 (www.openmarket.com) 或与他人共享 (www.clickatell.com) 您可以使用一项新服务 www.twilio.com 看起来不错但尚未对其进行测试。

If one way communication is all you need you could so something like email to gateway smsbut then you would need to know the carrier the end user is on.

如果您只需要一种方式通信,那么您可以使用电子邮件到网关短信之类的方式,但是您需要知道最终用户所在的运营商。

回答by Sunil Manheri

Fowiz offers free Android based solution to send/receive text messages from applications. You need to install their Android App on your device to enable this service and the messages are sent/received on your phone. You can setup CallbackUrl to receive instant notification on the incoming messages. Fowiz also supports short codes, campaign management, voting etc.

Fowiz 提供免费的基于 Android 的解决方案来从应用程序发送/接收文本消息。您需要在您的设备上安装他们的 Android 应用程序才能启用此服务,并在您的手机上发送/接收消息。您可以设置 CallbackUrl 以接收有关传入消息的即时通知。Fowiz 还支持短代码、活动管理、投票等。

Sample code to send message via Fowiz:

通过 Fowiz 发送消息的示例代码:

    String myPasscode = 'your passcode';
    String myUsername = 'your fowiz username';    
    String toPhoneNumber = 'recipient phone number';
    String myMessage = 'your message';

    HttpClient client = new DefaultHttpClient();
    HttpGet request = new HttpGet(HTTP_API + "?username="+myUsername
            "&phonenumber="+toPhoneNumber
    +"&message="+myMessage+"&passcode="+myPasscode);
    HttpResponse response = client.execute(request);

    BufferedReader rd = new BufferedReader
      (new InputStreamReader(response.getEntity().getContent()));

    String line = "";
    StringBuffer response = new StringBuffer();
    while ((line = rd.readLine()) != null) {
              response.append(line);
    }   

    System.out.println(response.toString());

Source: http://cloud.fowiz.com/2help.html

来源:http: //cloud.fowiz.com/2help.html

回答by Muhammad Sadiq

Yes you can build an API your own within 5 minutes. Your android phone can work as Server API to send and receive SMS in your Java code. It is very simple to do that. there are the some basic steps

是的,您可以在 5 分钟内构建自己的 API。您的 android 手机可以作为服务器 API 使用您的 Java 代码发送和接收短信。这样做非常简单。有一些基本步骤

  1. Download Android GSM Modem application from playstore in your phone GSM Modem FREE SMS in JAVA
  2. You also need helper tool to send or receive SMS without any disturbance. You also extend your functionality in android as well GSM Modem Helper Tool
  3. If you want to learn step by step. there is also guide and video tutorial. Send or receive FREE SMS in Java

    public class SMSSender {
    public static void main(String[] args) throws Exception{
    // TODO Auto-generated method stub
    String message = "Junk characters? method sendMultipartTextMessage only send text message. If you want to send non text message, you should look to method sendDataMessage. Below is the code excerpt from android cts. It has example on how to send long messages.";      
    String phone = "92***********";
    String username = "abcd";
    String password = "1234";
    String address = "http://192.168.1.101";
    String port = "8090";
    
    URL url = new URL(
            address+":"+port+"/SendSMS?username="+username+"&password="+password+
            "&phone="+phone+"&message="+URLEncoder.encode(message,"UTF-8"));
    
    URLConnection connection = url.openConnection();
    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    String inputLine;
    while((inputLine = bufferedReader.readLine()) !=null){
        System.out.println(inputLine);
    }
    bufferedReader.close();
    }
    }
    
  1. 从 Playstore 下载 Android GSM 调制解调器应用程序在您的手机GSM 调制解调器 JAVA 中的免费短信
  2. 您还需要帮助工具来发送或接收短信而不会受到任何干扰。您还可以在 android 以及GSM 调制解调器助手工具中扩展您的功能
  3. 如果你想一步一步地学习。还有指南和视频教程。用 Java 发送或接收免费短信

    public class SMSSender {
    public static void main(String[] args) throws Exception{
    // TODO Auto-generated method stub
    String message = "Junk characters? method sendMultipartTextMessage only send text message. If you want to send non text message, you should look to method sendDataMessage. Below is the code excerpt from android cts. It has example on how to send long messages.";      
    String phone = "92***********";
    String username = "abcd";
    String password = "1234";
    String address = "http://192.168.1.101";
    String port = "8090";
    
    URL url = new URL(
            address+":"+port+"/SendSMS?username="+username+"&password="+password+
            "&phone="+phone+"&message="+URLEncoder.encode(message,"UTF-8"));
    
    URLConnection connection = url.openConnection();
    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    String inputLine;
    while((inputLine = bufferedReader.readLine()) !=null){
        System.out.println(inputLine);
    }
    bufferedReader.close();
    }
    }