您现在的位置是:网站首页> 编程资料编程资料
python调用腾讯云实名认证接口辨别身份证真假_python_
2023-05-26
328人已围观
简介 python调用腾讯云实名认证接口辨别身份证真假_python_
今天给大家分享腾讯云的实名认证接口的调用
from __future__ import print_function import ssl, hmac, base64, hashlib from datetime import datetime as pydatetime try: from urllib import urlencode from urllib2 import Request, urlopen except ImportError: from urllib.parse import urlencode from urllib.request import Request, urlopen # 云市场分配的密钥Id secretId = "**购买后多得到的ID**" # 云市场分配的密钥Key secretKey = "**购买后得到的Key**" source = "**用户名**" # 签名 datetime = pydatetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT') signStr = "x-date: %s\nx-source: %s" % (datetime, source) sign = base64.b64encode(hmac.new(secretKey.encode('utf-8'), signStr.encode('utf-8'), hashlib.sha1).digest()) auth = 'hmac id="%s", algorithm="hmac-sha1", headers="x-date x-source", signature="%s"' % ( secretId, sign.decode('utf-8')) # 请求方法 method = 'GET' # 请求头 headers = { 'X-Source': source, 'X-Date': datetime, 'Authorization': auth, } ID_card = input('请输入你的身份证信息:') ID_name = input('请输入你的姓名:') # 查询参数 queryParams = { "idcard":ID_card, "name": ID_name} # body参数(POST方法下存在) bodyParams = { } # url参数拼接 url = 'https://service-2n5qa8cl-1256140209.ap-shanghai.apigateway.myqcloud.com/release/eid/check' if len(queryParams.keys()) > 0: url = url + '?' + urlencode(queryParams) request = Request(url, headers=headers) request.get_method = lambda: method if method in ('POST', 'PUT', 'PATCH'): request.data = urlencode(bodyParams).encode('utf-8') request.add_header('Content-Type', 'application/x-www-form-urlencoded') ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE response = urlopen(request, context=ctx) content = response.read() if content: print(content.decode('utf-8')) 运行结果:

“description”:“一致” 则说明身份证和人名一致则认证通过,否则不然。
以上就是python辨别身份真假之腾讯云身份证实名认证接口的详细内容,更多关于辨别身份真假之腾讯云身份证实名认证接口的资料请关注其它相关文章!
您可能感兴趣的文章:
相关内容
- 如何让Python在HTML中运行_python_
- python中dict获取关键字与值的实现_python_
- python类的私有属性和公共属性说明_python_
- python目标检测基于opencv实现目标追踪示例_python_
- Python中11种NumPy高级操作总结_python_
- pandas创建series的三种方法小结_python_
- pandas选择或添加列生成新的DataFrame操作示例_python_
- 对比分析BN和dropout在预测和训练时区别_python_
- 使用pyscript在网页中撰写Python程式的方法_python_
- python使用open函数对文件进行处理详解_python_
