当前位置:网站首页>漏刻有时API接口实战开发系列(14):身份证实名鉴权验证
漏刻有时API接口实战开发系列(14):身份证实名鉴权验证
2022-07-01 07:29:00 【漏刻有时】
项目需求
传入姓名、身份证号,校验此二要素是否一致,同时返回生日、性别、籍贯等信息。
项目请求
function getCard($idcard, $name)
{
$host = "https://eid.shumaidata.com";
$path = "/eid/check";
$method = "POST";
$appcode = "a277cc985ba54c388e72deb135d45e9d";
$headers = array();
array_push($headers, "Authorization:APPCODE " . $appcode);
$querys = "idcard=" . $idcard . "&name=" . urlencode($name);
$url = $host . $path . "?" . $querys;
$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, 1);
curl_setopt($curl, CURLOPT_HEADER, false);
if (strpos("$" . $host, "https://") == 1) {
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
$output = rtrim(curl_exec($curl), 1);//删除结尾的多余字符;
curl_close($curl);
return json_decode($output, true);
}
注意事项
多余字符处理
rtrim(curl_exec($curl), 1);//官方接口通过$curl爬取过来的内容,结尾存在“1”这样的异常数据,导致无法正常解析。通过rtrim函数删除结尾的多余字符。
API严谨性
同名不同身份证号也将审核通过。
@lockdata.cn
边栏推荐
- go-etcd
- 在券商账户上买基金安全吗
- How to draw a product architecture diagram?
- 5G Massive MIMO的概念和优点总结
- 【剑指offer&牛客101】中那些高频笔试,面试题——链表篇
- Redisson utilise la solution complète - redisson Documents officiels + commentaires (Partie 1)
- weback5基础配置详解
- 关于图灵测试和中文屋Chinese room的理解
- JSP - paging
- Vscode automatically formats code according to eslint specification
猜你喜欢

Are there any practical skills for operation and maintenance management

【编程强训3】字符串中找出连续最长的数字串+数组中出现次数超过一半的数字

组件的自定义事件②

Minecraft 1.16.5模组开发(五十一) 方块实体 (Tile Entity)

2022 tea master (intermediate) recurrent training question bank and answers

Ctfhub port scan (SSRF)

Open source! Wenxin large model Ernie tiny lightweight technology, accurate and fast, full effect

赌上了绩效,赢了公司CTO,我要搭DevOps平台!

Todolist classic case ①

熱烈祝賀五行和合酒成功掛牌
随机推荐
[lingo] solve quadratic programming
关于图灵测试和中文屋Chinese room的理解
The programmer of Beipiao posted a post for help late at night: I am lonely when my girlfriend is gone
C语言实现【三子棋游戏】(步骤分析和实现源码)
Apple账号密码自动填充
redisson使用全解——redisson官方文档+注释(上篇)
Detailed explanation of weback5 basic configuration
1286_FreeRTOS的任务优先级设置实现分析
Browser local storage
Unity2021-Scene视图中物体无法直接选中的解决办法
运维管理有什么实用的技巧吗
Microsoft announces open source (Godel) language model chat robot
I bet on performance and won the CTO of the company. I want to build Devops platform!
Apple account password auto fill
LeetCode+ 71 - 75
浅谈CVPR2022的几个研究热点
华为ModelArts训练Alexnet模型
How to create an exclusive vs Code theme
[软件] phantomjs屏幕截图
Those high-frequency written tests and interview questions in [Jianzhi offer & Niuke 101] - linked list