写一个php代码接收第三方平台推送的component_verify_ticket然后获取component_access_token并显示出来
时间: 2023-03-15 22:15:10 浏览: 130
微信开放平台-获取授权事件接收URL的component_verify_ticket php版本 版本太老了 不建议下载
3星 · 编辑精心推荐
<?php// 接收component_verify_ticket
$componentVerifyTicket = $_GET['component_verify_ticket'];// 请求component_access_token
$url = 'https://api.weixin.qq.com/cgi-bin/component/api_component_token';
$data = array(
'component_appid' => '你的appid',
'component_appsecret' => '你的appsecret',
'component_verify_ticket' => $componentVerifyTicket
);
$data = json_encode($data);$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);$result = curl_exec($curl);
$result = json_decode($result, true);
curl_close($curl);// 获取component_access_token
$componentAccessToken = $result['component_access_token'];// 显示出component_access_token
echo $componentAccessToken;
阅读全文