/*------------------------------------------------------------------------------
*
*
* 手机短信发送程序
* 类名:SendMsg
*
* Copyright (c), 2000,2002 Zhoutao
* All Rights Researved.
*
* Original Author: zhoutao tao_chou@21cn.com
* Last $Author: author $
*
* $Date: 2002-12-2 $
*
* $Id: id $
*
* To Do:
* sina的短信接口已经实现;
* 网易,shou还没添加.
*
------------------------------------------------------------------------------*/
import java.io.*;
import java.net.*;
public class SendMsg {
public static void main(String[] args) {
String query = "sname="+URLEncoder.encode("china");//发送人名称
query +="&msg="+URLEncoder.encode("Message"); //短信内容
query +="&mob1="+URLEncoder.encode("13800000000"); //手机号码1
query +="&mob2=13900000000"; //手机号码2
query +="&login=1"; //登陆方式
query +="&user=13600000000&passwd=123456"; //用户名和密码
try {
//URL u = new URL("http://sms.sina.com.cn/cgi-bin/sms/send.cgi?" + query);
URL u = new URL("http://sms.sina.com.cn/cgi-bin/sms/send.cgi");
URLConnection uc = u.openConnection();
uc.setDoInput(false);
uc.setDoOutput(true);
OutputStreamWriter out = new OutputStreamWriter(uc.getOutputStream());
out.write(query);
out.flush();
out.close();
}
catch (MalformedURLException e) {
System.err.println(e);
}
catch (IOException e) {
System.err.println(e);
}
}
}