游戏防沉迷系统相关内容

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

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;
}
相关推荐
曼巴UE51 小时前
UE5 制作游戏框架的部分经验积累(持续更新)
游戏·ue5
Buling_09 小时前
游戏中的设计模式——第一篇 设计模式简介
游戏·设计模式
lingran__14 小时前
C语言制作扫雷游戏(拓展版赋源码)
c语言·算法·游戏
D1555408805815 小时前
电竞护航小程序成品搭建三角洲行动护航小程序开发俱乐部点单小程序成品游戏派单小程序定制
游戏·小程序
nightunderblackcat1 天前
新手向:Python制作贪吃蛇游戏(Pygame)
python·游戏·pygame
王家视频教程图书馆1 天前
2025年最新 unityHub游戏引擎开发2d手机游戏和桌面游戏教程
游戏·unity·游戏引擎
点金石游戏出海1 天前
每周资讯 | 中国游戏市场将在2025年突破500亿美元;《恋与深空》收入突破50亿元
游戏·网易游戏·海外市场·恋与深空·手游市场
一点都不方女士1 天前
《无畏契约》游戏报错“缺少DirectX”?5种解决方案(附DirectX修复工具)
windows·游戏·microsoft·动态链接库·directx·运行库
wanhengidc2 天前
云手机可以息屏挂手游吗?
运维·网络·安全·游戏·智能手机
wanhengidc2 天前
云手机的空间会占用本地内存吗
科技·游戏·智能手机