通過驗(yàn)證碼短信http調(diào)用接口,您可以很快速的在網(wǎng)站或者app中集成手機(jī)號驗(yàn)證功能,該源碼只是核心代碼,具體可以根據(jù)您的實(shí)際需求進(jìn)行擴(kuò)展。
//import java.io.FileInputStream;
//import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.PostMethod;
public class sendsms {
private static String Url = "http://106.ihuyi.com/webservice/sms.php?method=Submit";
public static void main(String [] args) {
HttpClient client = new HttpClient();
PostMethod method = new PostMethod(Url);
//client.getParams().setContentCharset("GBK");
client.getParams().setContentCharset("UTF-8");
method.setRequestHeader("ContentType","application/x-www-form-urlencoded;charset=UTF-8");
String content = new String("您的驗(yàn)證碼是:7528。請不要把驗(yàn)證碼泄露給其他人。");
NameValuePair[] data = {//提交短信
new NameValuePair("account", "用戶名"),
new NameValuePair("password", "密碼"),
new NameValuePair("mobile", "手機(jī)號碼"),
new NameValuePair("content", content),
};
method.setRequestBody(data);
try {
client.executeMethod(method);
System.out.println(method.getResponseBodyAsString());
} catch (HttpException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//System.out.println("短信提交成功");
}
}
==================================================================
互億無線驗(yàn)證碼短信接口下載地址:http://www.xhl96.com/duanxin.html
如有疑問,請聯(lián)系我們的技術(shù),或者訪問我們的網(wǎng)站了解更多信息:http://www.xhl96.com/
新用戶促銷套餐,首購優(yōu)惠,直接下單購買
驗(yàn)證碼已發(fā)送到您的手機(jī),請查收!
輸入驗(yàn)證碼后,點(diǎn)擊“開通體驗(yàn)賬戶”按鈕可立即開通體驗(yàn)賬戶。