写一个php代码接收第三方平台推送的component_verify_ticket并显示出来
时间: 2023-03-15 09:15:11 浏览: 121
<?php
// 获取第三方平台推送的component_verify_ticket
$componentVerifyTicket = $_GET['component_verify_ticket'];// 显示component_verify_ticket
echo $componentVerifyTicket;
?>
相关问题
写一个php代码接收第三方平台推送的component_verify_ticket并解密显示出来
<?php
// 接收第三方平台推送的component_verify_ticket
$component_verify_ticket = $_POST["component_verify_ticket"];
// 用第三方平台提供的消息加密key解密component_verify_ticket
$key = "...";
$iv = "...";
$decrypted_component_verify_ticket = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $component_verify_ticket, MCRYPT_MODE_CBC, $iv);
// 打印出解密后的component_verify_ticket
echo $decrypted_component_verify_ticket;
?>
写一个PHP代码接收第三方推送的component_verify_ticket并获取component_access_token并显示的
<?php
//接收第三方推送的component_verify_ticket
$component_verify_ticket = $_GET['component_verify_ticket'];
//拼接url
$url = 'https://api.weixin.qq.com/cgi-bin/component/api_component_token';
//拼接请求数据
$data = '{"component_appid":"APPID","component_appsecret":"APPSECRET","component_verify_ticket":'.$component_verify_ticket.'}';
//发送请求
$return_data = request_post($url, $data);
//json字符串转换为数组
$return_data_arr = json_decode($return_data, true);
//获取component_access_token
$component_access_token = $return_data_arr['component_access_token'];
//显示component_access_token
echo "Component Access Token:".$component_access_token;
//发送post请求
function request_post($url = '', $param = '') {
if (empty($url) || empty($param)) {
return false;
}
$postUrl = $url;
$curlPost = $param;
$ch = curl_init();//初始化curl
curl_setopt($ch, CURLOPT_URL,$postUrl);//抓取指定网页
curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
$data = curl_exec($ch);//运行curl
curl_close($ch);
return $data;
}
?>
阅读全文