验证码短信接口java调用http源码

2013年07月25日

通过验证码短信http调用接口,您可以很快速的在网站或者app中集成手机号验证功能,该源码只是核心代码,具体可以根据您的实际需求进行扩展。

//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("您的验证码是:7528。请不要把验证码泄露给其他人。"); 

    

NameValuePair[] data = {//提交短信

    new NameValuePair("account", "用户名"), 

    new NameValuePair("password", "密码"),      

    new NameValuePair("mobile", "手机号码"), 

    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("短信提交成功");

}

 

 

==================================================================

互亿无线验证码短信接口下载地址:https://www.ihuyi.com/duanxin.html 

如有疑问,请联系我们的技术,或者访问我们的网站了解更多信息:https://www.ihuyi.com/

 


 

上一篇:验证码短信接口Delphi调用http源码

下一篇:验证码短信接口jsp调用http源码

互亿无线营销短信平台支持签名认证

为短信加上您的公司品牌和LOGO

在线咨询
服务热线:
4008 808 898

免费体验

填写验证码后,点击“开通体验账户”自动开通体验账户。

收不到短信验证码?
×