`
isiqi
  • 浏览: 16028718 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

java短信平台做法(要钱的)

阅读更多

做法1


我知道有两种方法啊   给你参考一下
第一:是获得移动、联通或电信的网关接口  这样就可以随意的免费接发短信
第二:设备,这个设备的原理是有一个可以插入多张手机卡,然后供应商会提供你的开发接口或者文档

做法2

今天在网上看到有人用java编写了发送短信的代码,原来以为是走什么样的方法,后来看了后知道就是在服务器上做好和短信服务商的接口后,java通过那个端口来控制发送的号码和内容。

估计这样群发短信就方便了,呵呵。

下面是代码,编译没问题,因为没有硬件环境所以没有办法运行(用到两个jar包:commons-net-1.4.1.jar和comm.jar):

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.smslib.IOutboundMessageNotification;
import org.smslib.OutboundMessage;
import org.smslib.Service;
import org.smslib.Message.MessageEncodings;
import org.smslib.modem.SerialModemGateway;

/**
* 短信发送类
*
*/
public class SMSUtil
{
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 void sendSMS(String mobilePhones,String content)
{
Service srv;
OutboundMessage msg;
OutboundNotification outboundNotification = new OutboundNotification();
srv = new Service();
SerialModemGateway gateway = new SerialModemGateway("modem.com1", "COM1", 115200, "wavecom", "9600");
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);
System.out.println(phones[i]+" == "+content);
}
srv.stopService();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
SMSUtil util = new SMSUtil(); //初始化
util.sendSMS("1590xxxxxxx","林春彬"); //输入电话号码和内容
}

}

做法3

有两种方式:
1.和专门的服务商合作,按照他们提供的接口进行开发就可以,例如:北京的亿美软通就是做短信平台提供的。

2.购买专门的短信发送设备,通过接口往设备端口进行短信的发送。

前者不但可以发送数据,还可以接受数据,获得发送是否成功,并且提供统一的短信回复号,比如:98888之类的,后者需要买SIM卡,发送短信的号码就是那个SIM卡的号码。
分享到:
评论
3 楼 david01205 2012-07-16  
楼主,你的很多文字都看不到。可以重新编辑你的页面吗?这样我们可以将你的代码和文字看完整。
2 楼 onezero8080 2011-12-12  
群发100000条短信怎么处理啊
1 楼 yinjie20101117 2011-10-19  
你那个做法2 你试过吗 我怎么有错了

相关推荐

Global site tag (gtag.js) - Google Analytics