如何从 Java 发送短信?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/545441/
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
How can I send an SMS from Java?
提问by
I wanted to send SMS to particular mobile from a Web application and receive his reply and view to a web application only. Is it possible to create using Java technology?
我想从 Web 应用程序向特定移动设备发送 SMS,并仅接收他对 Web 应用程序的回复和查看。是否可以使用 Java 技术进行创建?
回答by Steven Robbins
回答by lakshmanaraj
Few URLS to go through,
要经过的网址很少,
I recommend SMSLIB
我推荐SMSLIB
回答by Drona
The best way to achieve this is to use an SMS gateway. An SMS gateway encapsulates the technicalities of interfacing with SMS carrier medium on one hand and on other hand it provides an interface for application level protocols like http, SMTP, ftp etc. to interact with it. For example, you can have a web application talking to the SMS Gateway over HTTP and the gateway on its other side will talk to the SMS centre over some proprietory protocol to send the SMS text received from the application. Also, you can configure your Gateway to post the incoming SMS messages back to your web application. This way, the application need not know the low level protocols to send the SMSs.
实现这一目标的最佳方法是使用 SMS 网关。SMS 网关一方面封装了与 SMS 载体介质接口的技术细节,另一方面它为应用级协议(如 http、SMTP、ftp 等)提供了与之交互的接口。例如,您可以让 Web 应用程序通过 HTTP 与 SMS 网关通信,而其另一端的网关将通过某些专有协议与 SMS 中心通信,以发送从应用程序接收到的 SMS 文本。此外,您可以将网关配置为将传入的 SMS 消息发送回您的 Web 应用程序。这样,应用程序不需要知道发送 SMS 的低级协议。
You can lease a line to an SMS center (SMSC) if you need to send large number of bulk SMSs and configure your SMS gateway to use this lease line to send the msgs. But leasing a line is far more expensive. If you need to send small number of messages, then you can use your mobile phone in place of the leased line. Attach your mobile phone to your PC/Server and configure the Gateway to use your phone. You need to refer to your gateway documentation on interfacing your phone with the gateway. This is not very difficult but fairly simple.
如果您需要发送大量短信,您可以向短信中心(SMSC)租用一条线路,并将您的短信网关配置为使用这条租用线路发送短信。但租用线路要贵得多。如果您需要发送少量消息,那么您可以使用您的手机代替专线。将您的手机连接到您的 PC/服务器并配置网关以使用您的手机。您需要参考网关文档,了解如何将手机与网关连接起来。这不是很困难,但相当简单。
There are lot of commercial gateways available in the market which can be used. But using an open source SMS gateway is a good option. You can use an open source gateway called - Kannel. Believe me, it is not very difficult to set it up and start using.
市场上有很多可以使用的商业网关。但是使用开源 SMS 网关是一个不错的选择。您可以使用名为-Kannel 的开源网关。相信我,设置并开始使用并不是很难。