通過上面這個URL提交就可以發短信了
例如:[url]http://sms.api.bz/fetion.php?username=13800138000&password=123456&sendto=13912345678&message[/url]
於是寫了個無聊的代碼(解決剛纔的亂碼問題):
import java.io.IOException;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.params.HttpMethodParams;
class fection
{
static public void main(String []args) throws IOException
{
int i = 0;
while(i<3)//做人要厚道
{
String PostURL=("[url]http://sms.api.bz/fetion.php?username=&password=&sendto=&message[/url]
HttpClient client = new HttpClient();
PostMethod postMethod = new PostMethod(PostURL);
postMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET,"GBK");//發送中文,避免亂碼
postMethod.addParameter("username","135********");
postMethod.addParameter("password","mypassword");
postMethod.addParameter("sendto","136********");//立方
postMethod.addParameter("message","哈哈,可以發中文了,共3條,這是第"+Integer.toString(i+1)+"條");
client.setConnectionTimeout(10000);
client.executeMethod(postMethod);
i++;
}
System.out.println("OK!");
}
}
HttpClient竟然要用那麼多包,把我搞得暈暈的。。。
while(i<3)這個循環開始忘寫i++了,於是是一個死循環,用xx同學的手機測試,於是段性爆掉了他的手機,罪過罪過啊。。。。