求利用短信猫发短信的接口,写了一个好像不怎么对? 利用短信猫进行给用户发短信,接口怎么写,求各位高手指教。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 package com.alonely.notecat;import org.smslib.IOutboundMessageNotifica tion;import org.smslib.OutboundMessage;import org.smslib.Service;import org.smslib.Message.MessageEncodings;import org.smslib.modem.SerialModemGateway;public class SendMessage {? public class OutboundNotification implements IOutboundMessageNotifica tion {? ? public void process(String gatewayId, OutboundMessage msg) {? ? ? System.out.println("Outbound handler called from Gateway: "? ? ? ? ? + gatewayId);? ? ? System.out.println(msg);? ? }? }?@SuppressWarnings("deprecation")? public void sendSMS(String mobilePhones, String content) {? ? Service srv;? ? OutboundMessage msg;? ? OutboundNotification outboundNotification = new OutboundNotification();? ? srv = new Service();? ? SerialModemGateway gateway = new SerialModemGateway("modem.com3",? ? ? ? "COM3", 9600, "wavecom", ""); //设置端口与波特率? ? gateway.setInbound(true);? ? gateway.setOutbound(true);? ? gateway.setSimPin("0000");? ? gateway.setOutboundNotification(outboundNotification);? ? srv.addGateway(gateway);? ? System.out.println("初始化成功,准备开启服务");? ? try {? ? ? srv.startService();? ? ? System.out.println("服务启动成功");? ? ? String[] phones = mobilePhones.split(",");? ? ? for (int i = 0; i < phones.length; i++) {? ? ? ? msg = new OutboundMessage(phones[i], content);? ? ? ? msg.setEncoding(MessageEncodings.ENCUCS2); // 中文? ? ? ? srv.sendMessage(msg);? ? ? }? ? ? srv.stopService();? ? } catch (Exception e) {? ? ? e.printStackTrace();? ? }? }? public static void main(String[] args) {? ? SendMessage sendMessage = new SendMessage();? ? sendMessage.sendSMS("您要发送的手机号", "您要发送的内容!");? }} struts2,action里得不到页面传来的参数 获取Oracle过程的数据 eclipse开发webservice问题 把HIBERNATE的映射类用做STRUTS的FORMBEAN有什么看法? ireprot 中一个报表中的数据需要多个数据集,请问如何设置.?? 关于struts中logic:iterate的问题,急。 200分问一个弱智问题 怎么编一个软件让电脑自动重起啊~~~ 关于JDBC3.0初学的问题 jxl怎么实现从数据库导出到excel表格 顽固的struts2 乱码问题 ssh2 action中如何获取客户端的信息
package com.alonely.notecat;
import org.smslib.IOutboundMessageNotifica tion;
import org.smslib.OutboundMessage;
import org.smslib.Service;
import org.smslib.Message.MessageEncodings;
import org.smslib.modem.SerialModemGateway;public class SendMessage {
? public class OutboundNotification implements IOutboundMessageNotifica tion {
? ? public void process(String gatewayId, OutboundMessage msg) {
? ? ? System.out.println("Outbound handler called from Gateway: "
? ? ? ? ? + gatewayId);
? ? ? System.out.println(msg);
? ? }
? }
?@SuppressWarnings("deprecation")
? public void sendSMS(String mobilePhones, String content) {
? ? Service srv;
? ? OutboundMessage msg;
? ? OutboundNotification outboundNotification = new OutboundNotification();
? ? srv = new Service();
? ? SerialModemGateway gateway = new SerialModemGateway("modem.com3",
? ? ? ? "COM3", 9600, "wavecom", ""); //设置端口与波特率
? ? gateway.setInbound(true);
? ? gateway.setOutbound(true);
? ? gateway.setSimPin("0000");
? ? gateway.setOutboundNotification(outboundNotification);
? ? srv.addGateway(gateway);
? ? System.out.println("初始化成功,准备开启服务");
? ? try {
? ? ? srv.startService();
? ? ? System.out.println("服务启动成功");
? ? ? String[] phones = mobilePhones.split(",");
? ? ? for (int i = 0; i < phones.length; i++) {
? ? ? ? msg = new OutboundMessage(phones[i], content);
? ? ? ? msg.setEncoding(MessageEncodings.ENCUCS2); // 中文
? ? ? ? srv.sendMessage(msg);
? ? ? }
? ? ? srv.stopService();
? ? } catch (Exception e) {
? ? ? e.printStackTrace();
? ? }
? }
? public static void main(String[] args) {
? ? SendMessage sendMessage = new SendMessage();
? ? sendMessage.sendSMS("您要发送的手机号", "您要发送的内容!");
? }
}