소스 검색

调用问题

shish 5 년 전
부모
커밋
91d319cd48
3개의 변경된 파일4개의 추가작업 그리고 5개의 파일을 삭제
  1. 2 1
      app-pt/controllers/WxController.php
  2. 1 3
      common/components/miniUtil.php
  3. 1 1
      common/components/wxUtil.php

+ 2 - 1
app-pt/controllers/WxController.php

@@ -10,6 +10,7 @@ use bizHd\wx\classes\WxOpenClass;
 use bizHd\wx\services\WxBaseService;
 use bizHd\wx\services\WxOpenService;
 use bizHd\wx\services\WxSceneService;
+use common\components\miniUtil;
 use Yii;
 use common\services\xhMerchantExtendService;
 use common\services\xhShopService;
@@ -142,7 +143,7 @@ class WxController extends PublicController
             } elseif ($this->msgType == 'miniprogrampage') {
                 Yii::info('1243 ' . $this->fromUsername . ' ' . json_encode($merchant));
                 if ($postObj->PagePath == 'pagesClient/official/warn') {
-                    $r = wxUtil::sendMiniMsg('123456', $merchant, (string)trim($this->fromUsername), 1);
+                    $r = miniUtil::sendMsg('123456', $merchant, (string)trim($this->fromUsername), 1);
                     Yii::info('098' . ' ' . json_encode($r) . ' ' . $this->fromUsername . ' ' . json_encode($merchant));
                 }
             }

+ 1 - 3
common/components/miniUtil.php

@@ -482,7 +482,7 @@ class miniUtil
     //客服接口发消息
     public static function sendMsg($content, $merchant, $openId)
     {
-        $token = self::getAuthorizerAccessToken($merchant);
+        $token = self::getMiniProgramAccessToken($merchant);
         $url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={$token}";
         $data = ['touser' => $openId, 'msgtype' => 'text', 'text' => ['content' => $content]];
         $curl = new curl\Curl();
@@ -601,8 +601,6 @@ class miniUtil
 
     /**
      * 获取公众号的accessToken 公众号调用凭据
-     * @param unknown $appId
-     * @return unknown|string
      */
     public static function getAuthorizerAccessToken($merchant, $isOpen = 0)
     {

+ 1 - 1
common/components/wxUtil.php

@@ -480,7 +480,7 @@ class wxUtil
     {
         $token = self::getAuthorizerAccessToken($merchant, $isOpen);
         $url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={$token}";
-        $data = ['touser' => "owjM44wuUnytWRlNHrjIaxCenfRY", 'msgtype' => 'text', 'text' => ['content' => $content]];
+        $data = ['touser' => $openId, 'msgtype' => 'text', 'text' => ['content' => $content]];
         $curl = new curl\Curl();
         $result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
         $result = Json::decode($result);