文档概览

java

package com.ruanwei.interfacej;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class Test {
public static String url = "http://IP:端口/OutCallCode/SubmitCallCode.asp";
public static void main(String[] args) {
test();
// overage();
}
 
public static void test() {
try {
System.out.println("发送");
send("验证码","手机号码");
} catch (Exception e) {
e.printStackTrace();
}
}
 
public String send(String code, String mobile){
        String urlStr = url + "?username=用户名&password=密码&callid=唯一标示ID&phone=" + mobile + "&code=" + java.net.URLEncoder.encode(code, "UTF-8") + "";
URL url = new URL(urlStr);
HttpURLConnection huc = (HttpURLConnection) url.openConnection();
String result = "";
try {
huc.setRequestMethod("GET");
huc.connect();
InputStream is = huc.getInputStream();
int code = huc.getResponseCode();
if (code == HttpURLConnection.HTTP_OK) {
byte[] buffer = new byte[4096];
int bytes = 0;
while (true) {
bytes = is.read(buffer);
if (bytes <= 0) {
break;
}
result += new String(buffer);
}
} else {
result="err";
}
 
} finally {
try {
huc.disconnect();
} catch (Throwable ex) {
}
}
return result;
}
}
 
 
QQ在线咨询
服务热线
021-64360230
24小时电话
15900894283