游戏防沉迷系统相关内容

网站地址: 网络游戏防沉迷实名认证系统

PHP代码:

创建对应文件,在需要的位置get传参请求即可,具体参数参考 网络游戏防沉迷实名认证系统接口对接技术规范v2.0

1、上传信息

<?php
$url  ="https://wlc.nppa.gov.cn/test/authentication/check";

$config['appid'] = $_GET['appid'];

$config['bizid'] = $_GET['bizid'];

$config['timestamps'] = microsecond();

$config['secretKey'] =  $_GET['secretKey'];

$data['data'] = aesGcm($_GET['data'],$config['secretKey']);

$data = json_encode($data);
$str = $config['secretKey'].'appId'.$config['appid'].'bizId'.$config['bizid'].'timestamps'.$config['timestamps'].$data;

$config['sign'] = hash("sha256", $str);

$return = doHttpPost($url,$data,$config);

echo $return;

function aesGcm($data,$key)
{
        $key = hex2bin($key);
        $cipher = "aes-128-gcm";
        $ivlen = openssl_cipher_iv_length($cipher);
        $iv = openssl_random_pseudo_bytes($ivlen);
        $encrypt = openssl_encrypt($data, $cipher, $key, OPENSSL_RAW_DATA,$iv,$tag);
        return base64_encode(($iv.$encrypt.$tag));
}

function doHttpPost($url, $data,$config, $options = null)
{
        $headerArray =array('Content-Type:application/json;charset=utf-8','appId:'.$config['appid'],'bizId:'.$config['bizid'],'timestamps:'.$config['timestamps'],'sign:'.$config['sign']);
        
        //$header =array('Content-Type'=>'application/json;charset=utf-8','appId'=>$config['appid'],'bizId'=>$config['bizid'],'timestamps'=>$config['timestamps'],'sign'=>$config['sign']);
        
        
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,FALSE);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl,CURLOPT_HTTPHEADER,$headerArray);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($curl);
        curl_close($curl);
        return $output;
        
}
    
//时间戳
function microsecond()
{
        $t = explode(" ", microtime());
        $microsecond = round(round($t[1].substr($t[0],2,3)));
        return $microsecond;
}

2、查询信息

<?php
$ai = $_GET['ai'];

$url  ="http://api2.wlc.nppa.gov.cn/idcard/authentication/query?ai=".$ai;

$config['appid'] = $_GET['appid'];

$config['bizid'] = $_GET['bizid'];

$config['timestamps'] = microsecond();

$config['secretKey'] =  $_GET['secretKey'];

$str = $config['secretKey'].'ai'.$ai.'appId'.$config['appid'].'bizId'.$config['bizid'].'timestamps'.$config['timestamps'];

$config['sign'] = hash("sha256", $str);

$return = doHttpGet($url,$data,$config);

echo $return;

function doHttpGet($url, $data,$config, $options = null)
{
        $headerArray =array('appId:'.$config['appid'],'bizId:'.$config['bizid'],'timestamps:'.$config['timestamps'],'sign:'.$config['sign']);
  
        $curl = curl_init();
        //设置抓取的url
        curl_setopt($curl, CURLOPT_URL, $url);
        //设置头文件的信息作为数据流输出
        curl_setopt($curl, CURLOPT_HEADER, 0);
        // 超时设置,以秒为单位
        curl_setopt($curl, CURLOPT_TIMEOUT, 1);
     
        curl_setopt($curl, CURLOPT_HTTPHEADER, $headerArray);
        //设置获取的信息以文件流的形式返回,而不是直接输出。
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
        //执行命令
        $data = curl_exec($curl);
        
        return $data;
}
    
//时间戳
function microsecond()
{
        $t = explode(" ", microtime());
        $microsecond = round(round($t[1].substr($t[0],2,3)));
        return $microsecond;
}

3、行为上报

<?php
$url  ="https://api.wlc.nppa.gov.cn/idcard/authentication/check";

$config['appid'] = $_GET['appid'];

$config['bizid'] = $_GET['bizid'];

$config['timestamps'] = microsecond();

$config['secretKey'] =  $_GET['secretKey'];

$collections  = json_decode($_GET['collections'],true);

$collections  = json_encode(array('collections'=>array($collections)));

$data['data'] = aesGcm($collections,$config['secretKey']);

$data = json_encode($data);

$str = $config['secretKey'].'appId'.$config['appid'].'bizId'.$config['bizid'].'timestamps'.$config['timestamps'].$data;

$config['sign'] = hash("sha256", $str);

$return = doHttpPost($url,$data,$config);

echo $return;

function aesGcm($data,$key)
{
        $key = hex2bin($key);
        $cipher = "aes-128-gcm";
        $ivlen = openssl_cipher_iv_length($cipher);
        $iv = openssl_random_pseudo_bytes($ivlen);
        $encrypt = openssl_encrypt($data, $cipher, $key, OPENSSL_RAW_DATA,$iv,$tag);
        return base64_encode(($iv.$encrypt.$tag));
}

function doHttpPost($url, $data,$config, $options = null)
{
        $headerArray =array('Content-Type:application/json;charset=utf-8','appId:'.$config['appid'],'bizId:'.$config['bizid'],'timestamps:'.$config['timestamps'],'sign:'.$config['sign']);
        
        //$header =array('Content-Type'=>'application/json;charset=utf-8','appId'=>$config['appid'],'bizId'=>$config['bizid'],'timestamps'=>$config['timestamps'],'sign'=>$config['sign']);
        
        
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,FALSE);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl,CURLOPT_HTTPHEADER,$headerArray);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($curl);
        curl_close($curl);
        return $output;
        
}
    
//时间戳
function microsecond()
{
        $t = explode(" ", microtime());
        $microsecond = round(round($t[1].substr($t[0],2,3)));
        return $microsecond;
}
相关推荐
幻狐boke10 小时前
【游戏模组】星际争霸1代模组燃烧之地,泰伦帝国对决UED。特效华丽兵种巨多特别好玩
游戏
科技资讯早知道16 小时前
java计算机毕设课设—坦克大战游戏
java·开发语言·游戏·毕业设计·课程设计·毕设
程序猿阿伟2 天前
《C++游戏人工智能开发:开启智能游戏新纪元》
c++·人工智能·游戏
Artistation Game2 天前
九、怪物行为逻辑
游戏·unity·游戏引擎
妙为2 天前
unreal engine5制作动作类游戏时,我们使用刀剑等武器攻击怪物或敌方单位时,发现攻击特效、伤害等没有触发
游戏·游戏引擎·虚幻·碰撞预设
网站领航2 天前
服装时尚与动漫游戏的跨界联动:创新运营与策划策略研究
游戏·流量运营·用户运营
龙智DevSecOps解决方案2 天前
Perforce演讲回顾(上):从UE项目Project Titan,看Helix Core在大型游戏开发中的版本控制与集成使用策略
游戏·ue5·源代码管理·perforce·helix core
dangoxiba2 天前
[Unity Demo]从零开始制作空洞骑士Hollow Knight第十三集:制作小骑士的接触地刺复活机制以及完善地图的可交互对象
游戏·unity·visualstudio·c#·游戏引擎
新手unity自用笔记2 天前
项目-坦克大战学习-游戏结束
学习·游戏