三网手机号实名认证接口,是将【身份证号码、姓名、手机号码】上传至阿里云的接口API,再与运营商身份信息系统进行匹配,判断信息的一致性准确性。
首先我们获取接口:https://market.aliyun.com/detail/cmapi026061
购买完免费套餐后在控制台:marketnext.console.aliyun.com ,获取您的AppCode
具体实现代码【Java示例】:
import okhttp3.Call;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
public class phone3demo {
public static void main(String[] args) throws IOException {
String url = "https://phonecheck.market.alicloudapi.com/phoneAuthentication";
// 获取appCode链接:https://market.aliyun.com/detail/cmapi026061
String appCode = "e1f34lk456jl4k5j6k45660d7130";
String name = "张三";
String idNo = "240421193712211313";
String phoneNo = "13856565656";
System.out.println(postData(appCode, url, name, idNo, phoneNo));
}
/**依赖的工具包有:okhttp-3.2.0.jar, okio-1.14.0.jar
* 工具包下载链接:https://download.csdn.net/download/ruidongjun007/88360015
* <dependency>
* <groupId>com.squareup.okhttp3</groupId>
* <artifactId>okhttp</artifactId>
* <version>3.2.0</version>
* </dependency>
*
* <dependency>
* <groupId>com.squareup.okio</groupId>
* <artifactId>okio</artifactId>
* <version>1.14.0</version>
* </dependency>
*/
public static String postData(String appCode, String url, String name, String idNo, String phoneNo ) throws IOException {
String result = "";
RequestBody formBody = new FormBody.Builder().
add("name", name).add("idNo", idNo).add("phoneNo", phoneNo).build();
Request request = new Request.Builder().url(url).
addHeader("Authorization", "APPCODE " + appCode).post(formBody).build();
Call call = new OkHttpClient().newCall(request);
Response response = null;
try {
response = call.execute();
} catch (IOException e) {
System.out.println("execute failed, message:" + e.getMessage());
}
assert response != null;
if (!response.isSuccessful()) {
// 状态码为403时一般是套餐包用尽,需续购;
// 注意:续购不会改变秘钥(appCode),仅增加次数
// 续购链接:https://marketnext.console.aliyun.com/bizlist
System.out.println("request failed----" + "返回状态码" + response.code() +
",message:" + response.message());
}
result = response.body().string();
// 返回实例:{"name":"张三","idNo":"240421193712211313","phoneNo":"13856565656","respMessage":"身份证信息匹配","respCode":"0000"}
return result;
}
}