sendmessage.java
来自「使用smslib和GSP modem 发送和接收手机短息」· Java 代码 · 共 64 行
JAVA
64 行
// SendMessage.java - Sample application.
//
// This application shows you the basic procedure for sending messages.
// You will find how to send synchronous and asynchronous messages.
//
// For asynchronous dispatch, the example application sets a callback
// notification, to see what's happened with messages.
//
// Bulk Operator used: BULKSMS (http://www.bulksms.com)
// Please look the BulkSmsHTTPGateway documentation for details.
package examples.bulksms;
import org.smslib.Library;
import org.smslib.OutboundMessage;
import org.smslib.Service;
import org.smslib.http.BulkSmsHTTPGateway;
public class SendMessage
{
public void doIt() throws Exception
{
Service srv;
OutboundMessage msg;
System.out.println("Example: Send message from BulkSMS HTTP Interface.");
System.out.println(Library.getLibraryDescription());
System.out.println("Version: " + Library.getLibraryVersion());
srv = new Service();
BulkSmsHTTPGateway gateway = new BulkSmsHTTPGateway("bulksms.http.1", "username", "password");
gateway.setOutbound(true);
srv.addGateway(gateway);
srv.startService();
// Query the service to find out our credit balance.
System.out.println("Remaining credit: " + gateway.queryBalance());
// Send a message synchronously.
msg = new OutboundMessage("+30...", "Hello World!");
srv.sendMessage(msg);
System.out.println(msg);
System.out.println("Now Sleeping - Hit <enter> to terminate.");
System.in.read();
srv.stopService();
}
public static void main(String args[])
{
SendMessage app = new SendMessage();
try
{
app.doIt();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?