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卡的号码。

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值