三方平台管理公众号----component_verify_ticket

验证票据(component_verify_ticket):
在第三方平台创建审核通过后,微信服务器会向其 授权事件接收URL 每隔 10 分钟以 POST 的方式推送 component_verify_ticket
在这里插入图片描述
component_verify_ticket 数据内容:


2020-11-07 00:26:12|三方平台|get|{"signature":"6e51866e3468e6dc5dba147df5f9f0897b0db3d6","timestamp":"1604679973","nonce":"1054256936","encrypt_type":"aes","msg_signature":"63c5475632f144cdcefaece6e37e8f656dc18dde"}
2020-11-07 00:26:12|三方平台|post xml|
<xml>
    <AppId><![CDATA[wx6d80ca40ad4e00fc]]></AppId>
    <Encrypt><![CDATA[tGwCwDUxxkdcdsggmCxORKgjXB7M0VKBr77rdl8hW9vSFfNVzt5nSHrOybIX+s78EU3Gq2OurphIXo9viNk7bngFsVO3RDvxmEv6ZQ6gDetp1j2LgPUlQt9/SVcoiYg0V/6W08Xt7o/Xr3cCyZw7+AJYIkEWMJt1IKpJtvqvnQ/5VGUa6D3/ymaKGyXD/jThz3myqwlScJm1LTOFdjO+PnP5DBVzQXaXVbAPBMiMbOyzSkDOmcpwIDkKZzMUEXt6IwcE/2Q2wojyvzL4ygne1fp5/X3W7UiCwGlcGL3O08APWraAEDuSEwYj8fqI8vITQ9BC4EiNex00tDIPyTcxOH8wzMZa83xkzA1m30EauzFihPRUQUJeZXYXCxeloif4uRK+r8nQUVc83zPdTL9PQGnQm6iLMTrjIx4zLPnt4ELBp7wxJw5FPJR0TLjJxUXCNeT3VVVxaa9dAGxfaOB0BA==]]></Encrypt>
</xml>
2020-11-07 00:26:12|三方平台|post Encrypt|{"AppId":"wx6d09ca67ad4e12fc","Encrypt":"UQvHcffGbS+EWpX082f9BTOqHMuf5A7SsZerEVd5ATrl7DHnu4heOiYqj0EHsrrjKTA6Nm479zprJhFrQQlcXEeC1hqrFGO5ZyZv2cQGpVPE4OfcRp6B\/O\/med+oZsEYgZKsVvAKx+yBJyfnF6QXK+AzPz1EtiQsq7glKI1M\/JUrTDtvOZgdfVbXNVOyRUe7uUbAn+8tNGbKtGhkxE9b2bEriim3lVc7+9uT0LIOutz+WMCfODKZ4qfsG+trRdzLck7kgRQzT8RRA+68FMGRqwkHus27+xnh1Vr6fekVz84N6YDw9jLbBVuVOF9DHiSVFwUqDIPSMPiOB+FMWLZ5yBjGrV7QjNSGtGLQNDr97Pm7181bYlZaxNwE8AlqSMDLSFnl+mt+RuQDEJMSSzsjIOgWzgga9\/nBRtszGKzlLrq0KSEpCPSe0Bj3+bxGb3EJjPmn+E8ynT506tdHPa2FBw=="}
2020-11-07 00:26:12|三方平台|post Decrypt|{"AppId":"wx6d09ca67ad4e12fc","CreateTime":"1604679973","InfoType":"component_verify_ticket","ComponentVerifyTicket":"ticket@@@BJK2yMRAfj5RmWWtJbKK19TJ9U1w0xOetxBk9AsIN5bFx4GkHWYlgoBYuXCD15rb-qBiidzhVTbeZTm2V-JaWQ"}
2020-11-07 00:26:12|三方平台|component_verify_ticket|ticket@@@BJK2yMRAfj5RmWWtJbKK19TJ9U1w0xOetxBk9AsIN5bFx4GkHWYlgoBYuXCD15rb-qBiidzhVTbeZTm2V-JaWQ

下面介绍auth_notify.php如何接收component_verify_ticket
1.0 auth_notify.php 直接返回字符串 success,通知微信此次message已成功接收;
2.0 获取GET数据: $_GET
3.0 获取POST数据:$xmlData = file_get_contents(‘php://input’),并将xml转为数组
4.0 xml转为数组后,得到的是加密数据,需要进行解密,本人微信开发都是基于EasyWechat开发,已经封装好Encrypt/Decrypt方法,参数准备好,直接调用即可,原生加解代码可参考微信开发文档:加密解密技术方案
注:WX_Component.php
在这里插入图片描述
附件 auth_notify.php:

<?php
/**
 * 三方平台 - 授权事件
 */

//接收 POST 请求后,只需直接返回字符串 success
echo "success";
require_once dirname(__FILE__) . '/../init.php';

use PhalApi\Tool;
use EasyWeChat\Kernel\Encryptor;
use WKTF\Domain\Component;

\PhalApi\DI()->logger->log('三方平台', 'auth_notify','begin');
if(isset($_GET['nonce'])){
    //get参数
    \PhalApi\DI()->logger->log('三方平台', 'get', $_GET);
    $nonce          = $_GET['nonce'];
    $timestamp      = $_GET['timestamp'];
    $encrypt_type   = $_GET['encrypt_type'];
    $msg_signature  = $_GET['msg_signature'];

    $config      = \PhalApi\DI()->config->get('WX_Component'); 
    $Encryptor   = new Encryptor($config['app_id'], $config['token'], $config['aes_key']);
    $D_Component = new Component();

    //post参数
    $raw_arr = Tool::xmlToArray(file_get_contents('php://input'));
    $Encrypt = $raw_arr['Encrypt'];
    \PhalApi\DI()->logger->log('三方平台', 'post Encrypt', $raw_arr);

    //解码 三方平台验证票据
    $raw_arr = Tool::xmlToArray($Encryptor->decrypt($Encrypt, $msg_signature, $nonce, $timestamp));
    \PhalApi\DI()->logger->log('三方平台', 'post Decrypt', $raw_arr);

    $InfoType = $raw_arr['InfoType'];
    switch ($InfoType) {
        case 'component_verify_ticket': 
            //验证票据:每隔10分钟以 POST 的方式推送
            $D_Component->notifyComponentVerifyTicket($raw_arr);
            break;
        case 'authorized': 
            //授权             
            $D_Component->notifyAuthorized($raw_arr);
            break;
        case 'unauthorized':   
            //取消授权         
            $D_Component->notifyUnAuthorized($raw_arr);
            break;
        case 'updateauthorized':
            //更新授权         
            $D_Component->notifyUpdateAuthorized($raw_arr);
            break;
        default:
            \PhalApi\DI()->logger->log('三方平台', 'InfoType', $InfoType);
     }
}
\PhalApi\DI()->logger->log('三方平台', 'auth_notify','end');
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值