用飞信发送短信

最近看到一个好东西,可以用来发免费的短信,有兴趣的可以试下....
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();
}


}

问题:

一 java.lang.UnsupportedClassVersionError: Bad version number in .class file
必须使用jdk 1.6

二 Exception in thread "main" java.lang.RuntimeException: Your license has expired. Please registe ...,Your key is @2AC*1A97~C@6DCF6B8FEFE03@6B4C&CCAFF92
      需要key的

       可以去这弄http://javaghl.appspot.com/fetionApi.jsp 上将key 值输入,点击"获取license".

把------之间的内容保存为文件license(无后缀,注意不要使文件首尾有空行或者空格出现),放在你程序的当前目录下 ,eclipse项目默认为项目根目录下(src目录的上层目录),web项目放到tomcat的bin目录下.

ok!~

但我的登录太慢了!~~

你可能感兴趣的:(eclipse,jdk,tomcat,jsp,Web)