当前位置: 首页 > news >正文

游戏防沉迷系统相关内容

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

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();//设置抓取的urlcurl_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;
}

http://www.lryc.cn/news/324351.html

相关文章:

  • 每日OJ题_牛客_JD1 年终奖(动态规划)
  • 深度学习 tablent表格识别实践记录
  • 深度学习 线性神经网络(线性回归 从零开始实现)
  • HBase在表操作--显示中文
  • 基于BusyBox的imx6ull移植sqlite3到ARM板子上
  • 连续子数组的最大和
  • Photoshop 工具使用详解(全集 · 2024版)
  • C++函数返回机制,返回类型
  • [linux] Key is stored in legacy trusted.gpg keyring
  • 阿里云部署OneApi
  • MapReduce学习问题记录
  • Elasticsearch优化
  • 【Redis知识点总结】(六)——主从同步、哨兵模式、集群
  • Java面试题:设计一个线程安全的单例模式,并解释其内存占用和垃圾回收机制;使用生产者消费者模式实现一个并发安全的队列;设计一个支持高并发的分布式锁
  • 【硬件设计】以立创EDA举例——持续更新
  • Chain of Note-CoN增强检索增强型语言模型的鲁棒性
  • Uniapp 的 uni.request传参后端
  • 数据可视化-ECharts Html项目实战(5)
  • C++学习之旅(二)运行四个小项目 (Ubuntu使用Vscode)
  • 数据分析与挖掘
  • Maxwell监听mysql的binlog日志变化写入kafka消费者
  • Kafka系列之:Kafka Connect REST API
  • DC-4靶机
  • ideaSSM 高校公寓交流员管理系统bootstrap开发mysql数据库web结构java编程计算机网页源码maven项目
  • Android studio添加阿里云仓库
  • 每天一个数据分析题(二百二十)
  • Centos上安装Harbor并使用
  • 工作需求,Vue实现登录
  • 【生产力】Mac 窗口布局工具 Magnet
  • Linux的相关指令总结