代码:
include_once "/vendor/weworkapi/callback/WXBizMsgCrypt.php";
$token = "YmEc";
$corpId = "wwd4099530cxxxx";
$encodingAesKey = "emvOcYJBT3SVLGbzeYxHbg9HobQW5S448W85kRDaaa";
// 需要返回的明文
$sEchoStr = "";
$wxcpt = new \WXBizMsgCrypt($token, $encodingAesKey, $corpId);
$sVerifyMsgSig = $_GET["msg_signature"];
$sVerifyTimeStamp = $_GET["timestamp"];
$sVerifyNonce = $_GET["nonce"];
$sVerifyEchoStr = $_GET["echostr"];
$errCode = $wxcpt->VerifyURL($sVerifyMsgSig, $sVerifyTimeStamp, $sVerifyNonce, $sVerifyEchoStr, $sEchoStr);
file_put_contents('aaaa.txt',$sEchoStr, FILE_APPEND );
file_put_contents('aaaa.txt',$errCode, FILE_APPEND);
if ($errCode == 0)
{
echo $sEchoStr;
} else {
print("ERR: " . $errCode . "\n\n");
}
我在日志中获取到返回的$errCode = 0的,但是$sEchoStr 却是空的
请问大家的$sEchoStr是什么样的呢?在验证的时候老是无法通过
您好,echostr 是一串字符串在通过接收消息的URL中获取,需要解密得到消息内容明文,解密可以先看下加解密文档https://work.weixin.qq.com/api/doc/90000/90139/90968