如何用php开启企业微信开发的回调模式
1个回答
展开全部
<?php
include_once "WXBizMsgCrypt.php";
$qy= new Qy_wechat();
$qy->test1();
$qy->valid();
class Qy_wechat{
private $token;
private $encodingAesKey;
private $corpId;
function __construct()
{
$this->token='heTIurA65In';
$this->encodingAesKey='k8UmbddUc83SC3sGEyafepiycJNBj6Iw0JGXmkp1weh';
$this->corpId='WW4e37698eeb6f73c5';
}
public function valid(){
$sVerifyMsgSig =$_GET["msg_signature"];
$sVerifyTimeStamp =$_GET["timestamp"];
$sVerifyNonce = $_GET["nonce"];
$sVerifyEchoStr = $_GET["echostr"];// 需要返回的明文
$wxcpt = new WXBizMsgCrypt($this->token, $this->encodingAesKey, $this->corpId);
$errCode = $wxcpt -> VerifyURL($sVerifyMsgSig, $sVerifyTimeStamp, $sVerifyNonce, $sVerifyEchoStr, $sEchoStr);
if ($errCode == 0) {
//
// 验证URL成功,将sEchoStr返回
echo $sEchoStr;
} else {
print("ERR: " . $errCode . "\n\n");
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询