Esempio n. 1
0
 /**
  * 对接企业号
  */
 public function join($params)
 {
     $msg_signature = $params['msg_signature'];
     $timestamp = $params['timestamp'];
     $nonce = $params['nonce'];
     $echostr = $params['echostr'];
     $logger = TMS_APP::M('log');
     $mpa = TMS_APP::G('mp\\mpaccount');
     $sEchoStr = '';
     $wxcpt = new WXBizMsgCrypt($mpa->token, $mpa->qy_encodingaeskey, $mpa->qy_corpid);
     $errCode = $wxcpt->VerifyURL($msg_signature, $timestamp, $nonce, $echostr, $sEchoStr, $logger);
     if ($errCode == 0) {
         /**
          * 如果存在,断开公众号原有连接
          */
         TMS_APP::model()->update('xxt_mpaccount', array('qy_joined' => 'N'), "qy_corpid='{$mpa->qy_corpid}' and qy_secret='{$mpa->qy_secret}'");
         /**
          * 确认建立连接
          */
         TMS_APP::model()->update('xxt_mpaccount', array('qy_joined' => 'Y'), "mpid='{$this->mpid}'");
         return array(true, $sEchoStr);
     } else {
         return array(false, $errCode);
     }
 }
Esempio n. 2
0
 /**
  * 微信开发者模式验证的签名
  * @param $token string
  */
 public function check_signature()
 {
     $msg_signature = urldecode(\Core\URI::kv('msg_signature', ''));
     $timestamp = urldecode(\Core\URI::kv('timestamp', ''));
     $nonce = urldecode(\Core\URI::kv('nonce', ''));
     $echostr = urldecode(\Core\URI::kv('echostr', ''));
     $decode_echostr = '';
     $wxcpt = new \WXBizMsgCrypt($this->token, $this->encodingaeskey, $this->corpid);
     //进行地址解析
     $errcode = $wxcpt->VerifyURL($msg_signature, $timestamp, $nonce, $echostr, $decode_echostr);
     if ($errcode == 0) {
         return $decode_echostr;
     }
     return false;
 }
Esempio n. 3
0
<?php

include_once "WXBizMsgCrypt.php";
$encodingAesKey = "nil3OzTxXoPHx4mvx0GLbyECkPYrfyiB9ca4Iz61ny3";
$token = "N6cq3R";
$corpId = "wx926454a4965d2b7c";
$sVerifyMsgSig = $_GET["msg_signature"];
$sVerifyTimeStamp = $_GET["timestamp"];
$sVerifyNonce = $_GET["nonce"];
$sVerifyEchoStr = $_GET["echostr"];
$EchoStr = "";
$wxcpt = new WXBizMsgCrypt($token, $encodingAesKey, $corpId);
$errCode = $wxcpt->VerifyURL($sVerifyMsgSig, $sVerifyTimeStamp, $sVerifyNonce, $sVerifyEchoStr, $sEchoStr);
if ($errCode == 0) {
    echo $sEchoStr;
} else {
    print "ERR: " . $errCode . "\n\n";
}