📄 clickatellsendmessage.java
字号:
// 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: Clickatell (http://www.clickatell.com)
// Please look the ClickatellHTTPGateway documentation for details.
package org.ajwcc.pduUtils.test.integration;
import org.smslib.*;
import org.smslib.http.*;
public class ClickatellSendMessage extends AbstractTester
{
@Override
public void test() throws Exception
{
OutboundMessage msg;
OutboundNotification outboundNotification = new OutboundNotification();
System.out.println("Example: Send message from Clickatell HTTP Interface.");
System.out.println(Library.getLibraryDescription());
System.out.println("Version: " + Library.getLibraryVersion());
ClickatellHTTPGateway gateway = new ClickatellHTTPGateway("clickatell.http.1", " 2982992", "tdelenikas", "AFghjkr3");
gateway.setOutbound(true);
gateway.setOutboundNotification(outboundNotification);
// Do we need secure (https) communication?
// True uses "https", false uses "http" - default is false.
gateway.setSecure(true);
srv.addGateway(gateway);
gateway.startGateway();
// Create a message.
msg = new OutboundMessage("+639183018888", "Hello from SMSLib (Clickatell handler)");
msg.setFrom("SMSLIB.ORG");
// Ask for coverage.
System.out.println("Is recipient's network covered? : " + gateway.queryCoverage(msg));
// Send the message.
gateway.sendMessage(msg);
System.out.println(msg);
System.out.println(msg.getPduUserDataHeader());
// Now query the service to find out our credit balance.
System.out.println("Remaining credit: " + gateway.queryBalance());
System.out.println("Now Sleeping - Hit <enter> to terminate.");
System.in.read();
srv.stopService();
}
public class OutboundNotification implements IOutboundMessageNotification
{
public void process(String gatewayId, OutboundMessage msg)
{
System.out.println("Outbound handler called from Gateway: " + gatewayId);
System.out.println(msg);
}
}
public static void main(String args[])
{
ClickatellSendMessage app = new ClickatellSendMessage();
try
{
app.initModem();
app.test();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -