本帖最后由 namecxz 于 2021-10-8 10:37 编辑
我学习时写的一个很简单的网页,用来调用二要素认证的api接口,界面很简陋,数据调用后没有整理。
本人新手,大佬勿喷。
接口代码展示
[PHP] 纯文本查看 复制代码 <?php
$host = "https://dfidveri.market.alicloudapi.com";
$path = "/verify_id_name";
$method = "POST";
$appcode = $_POST['AppCode'];//AppCode
$sfz = $_POST['sfz'];//身份证号码
$sfz_cl = "id_number=";//身份证变量名称
$name = $_POST['name'];//姓名
$name_cl = "&name=";//姓名变量名称
$fh = "&";//连接符号
$headers = array();
array_push($headers, "Authorization:APPCODE " . $appcode);
//根据API的要求,定义相对应的Content-Type
array_push($headers, "Content-Type".":"."application/x-www-form-urlencoded; charset=UTF-8");
$querys = "";
$bodys = $sfz_cl.$sfz.$fh.$name_cl.$name;//变量拼接
$url = $host . $path;
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, true);
if (1 == strpos("$".$host, "https://"))
{
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys);
var_dump(curl_exec($curl));
?>
调用代码展示
[HTML] 纯文本查看 复制代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>身份证二要素实名认证</title>
<style type="text/css">
</style>
</head>
<body>
<div>
<form action="api.php" method="post">
AppCode: <input name="AppCode" type="text" />
身份证号: <input name="sfz" type="text" />
姓名: <input name="name" type="text" />
<input type="submit" />
</form>
<div>
AppCode购买地址: <a >点击跳转</a>
</div>
</body>
</html>
身份证二要素实名认证.zip
(1.41 KB, 下载次数: 30)
|