PHP对接网络游戏防沉迷实名认证系统
本次开发是自己结合他人的经验开发,但是源文章找不到了,所以自己写了一篇,直接上代码
<?php
namespace Handlers;
class NetworkRealname {
protected $biz_id;
protected $app_id;
protected $secret_key;
public function __construct()
{
$this->biz_id = "";
$this->app_id = "";
$this->secret_key = "";
}
/*
* 请求身份验证接口
* $name 姓名,$card 身份证号,$member_id 平台用户id,$test_code 测试码
*/
function getIdCard($name,$card,$member_id,$test_code='')
{
$timestamps = $this->getMillisecond(); //当前毫秒时间戳
$url = 'https://api.wlc.nppa.gov.cn/idcard/authentication/check';
if($test_code) {
$this->secret_key = 'caebad8c543aa2154b325f9831baa'; //测试secret_key
$this->app_id = '36fce80d09454712bbb0a7c52ec16'; //测试appId
$this->biz_id = '1101999999'; //测试bizId
$url = 'https://wlc.nppa.gov.cn/test/collection/loginout/'.$test_code;
}
$head = ['appId'=>$this->app_id,'bizId'=>$this->biz_id,'timestamps'=>$timestamps];
//请求头
$header[] = 'Content-Type:application/json;charset=utf-8';
$header[] = 'appId:' . $this->app_id;
$header[] = 'bizId:' . $this->biz_id;
$header[] = 'timestamps:' . $timestamps;
//请求体
$body['ai'] = m