日期:2014-05-20  浏览次数:20736 次

用java和飞信来发免费短信
最近看到一个好东西,可以用来发免费的短信,有兴趣的可以试下....
http://download.csdn.net/source/1148854
用起来很方便,只需要这一个jar包
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 ExampleMain {
public static void main(String[] args) throws Exception{
final Fetion fetion = new Fetion("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();
}






------解决方案--------------------
不错的东东,先收藏了
------解决方案--------------------
没人顶?????????
------解决方案--------------------
试试看
------解决方案--------------------
100%能用






------解决方案--------------------
Java code
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 ExampleMain {
    public static void main(String[] args) throws Exception{
        final Fetion fetion = new Fetion("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();
    }
    
    
}

------解决方案--------------------
用不了 
告诉一下具体方法
import的东西去哪找
------解决方案--------------------
上次发同学,他的网络是通过代理连接的,所以不能用,自己的机器上是可以用的,就怕移动做手脚.......