PHP腾讯云人脸核身获取SIGN Ticket

参考腾讯云官方文档:人脸核身 获取 SIGN ticket_腾讯云

前提条件:已经获取了access_token。获取方法可参考:

PHP腾讯云人脸核身获取Access Token-CSDN博客

php 复制代码
public function getSignTicket(){
        

    $access_token = file_get_contents('/data/config/tx_face_accesstoken.txt');

    if(!$access_token){
        return;
    }

    $data = [
        'appId' => '', //WBappid,https://cloud.tencent.com/document/product/1007/49634
        'access_token' => $access_token,
	    'type' => 'SIGN', 
        'version' => '1.0.0'
    ];

    $str = http_build_query($data);
    $url = 'https://kyc1.qcloud.com/api/oauth2/api_ticket?'.$str;
        
    $result = $this->cmf_curl_get($url);

    $arr = json_decode($result,true);

    if($arr['code'] == 0){
        $ticket = $arr['tickets'][0]['value'];
        //写入磁盘
        file_put_contents('/data/config/tx_face_signticket.txt',$ticket);
    }
}

function cmf_curl_get($url){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_FAILONERROR, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_AUTOREFERER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    $SSL = substr($url, 0, 8) == "https://" ? true : false;
    if ($SSL) {
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 信任任何证书
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // 检查证书中是否设置域名
    }
    $content = curl_exec($ch);
    curl_close($ch);
    return $content;
}
相关推荐
Mr数据杨18 小时前
【腾讯云智能体】志愿填报联网搜索与知识库问答
云计算·腾讯云
翼龙云_cloud18 小时前
腾讯云代理商:腾讯云部署的Hermes Agent如何接入QQ ?
人工智能·云计算·腾讯云·ai智能体·hermes agent
Inhand陈工2 天前
智能驾驶数据高可靠上云实战:EC3320+IR315双路冗余方案
网络·物联网·自动驾驶·智能路由器·边缘计算·腾讯云·信息与通信
池央2 天前
基于腾讯云架构部署OpenClaw并实现与Telegram终端集成的全链路技术解析与实践指南
架构·云计算·腾讯云·腾讯云openclaw玩虾大赛
熊猫钓鱼>_>2 天前
当“虾”遇上“马”:QClaw 融合 Hermes 背后的智能体进化论
人工智能·ai·腾讯云·agent·openclaw·qclaw·hermes
OpenClawCSDN3 天前
2026年腾讯云如何安装和集成Hermes Agent/OpenClaw?深度剖析
数据库·阿里云·云计算·腾讯云·京东云
云存储小天使4 天前
构筑数据磐石:腾讯云自研磁带引擎技术剖析
腾讯云·对象存储·深度归档存储
m0_466525295 天前
东软智行与腾讯云达成战略合作 共筑AI智能座舱新生态
人工智能·microsoft·腾讯云
TG_yunshuguoji5 天前
腾讯云代理商:腾讯云怎么一键部署Hermes?
人工智能·云计算·腾讯云·hermes agent·hermes