Blame view

addons/antis/controller/Wx.php 1.45 KB
2db47680   hexiaodong   chore: 初始提交 php 遗...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  <?php

  

  namespace addons\antis\controller;

  

  use addons\antis\model\Staff;

  use addons\antis\model\AdminConfig;

  use think\Log;

  use WeWork\Crypt\WXBizMsgCrypt;

  

  /**

   *  * 操作文档:https://doc.fastadmin.net/antis

   * 软件介绍:https://www.fastadmin.net/store/antis.html

   * 售后微信:qingdong_crm

   * 企业微信接口

   */

  class Wx extends StaffApi

  {

      protected $noNeedLogin = ['userid','template','token'];

      protected $noNeedRight = [];

  

  

      public function _initialize()

      {

          parent::_initialize();

      }

  

      //验证

      public function token()

      {

          $corpId = AdminConfig::getConfigValue('wechat', 'corpid');

          $token = '';

          $encodingAesKey = '';

          Log::write('a---' . json_encode($_GET));

  

          $sVerifyMsgSig = input('msg_signature');

          $sVerifyTimeStamp = input('timestamp');

          $sVerifyNonce = input('nonce');

          $sVerifyEchoStr = input('echostr');

  

          if (empty($sVerifyMsgSig) || empty($sVerifyTimeStamp) || empty($sVerifyNonce) || empty($sVerifyEchoStr)) {

              $this->error('参数不正确');

          }

  

          $sEchoStr = "";

          $wxcpt = new WXBizMsgCrypt($token, $encodingAesKey, $corpId);

          $errCode = $wxcpt->VerifyURL($sVerifyMsgSig, $sVerifyTimeStamp, $sVerifyNonce, $sVerifyEchoStr, $sEchoStr);

          if ($errCode == 0) {

              return $sEchoStr;

          } else {

              return false;

          }

      }

  

  

  }