瀏覽代碼

Merge branch 'wx-kw' into test

# Conflicts:
#	modules/Channel/Http/Controllers/WechatOpenPlatformController.php
zqwang 1 年之前
父節點
當前提交
6cd253229a
共有 1 個文件被更改,包括 8 次插入12 次删除
  1. 8 12
      modules/Channel/Http/Controllers/WechatOpenPlatformController.php

+ 8 - 12
modules/Channel/Http/Controllers/WechatOpenPlatformController.php

@@ -3,7 +3,9 @@
 namespace Modules\Channel\Http\Controllers;
 
 use Catch\Base\CatchController;
+use EasyWeChat\OpenPlatform\Application;
 use EasyWeChat\OpenPlatform\Server\Guard;
+
 use Illuminate\Foundation\Validation\ValidatesRequests;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
@@ -124,9 +126,9 @@ class WechatOpenPlatformController extends CatchController
     {
 
         $componentInfo = WechatOpenPlatformService::getComponentInfoByAppid($component_appid);
-        $app = WechatOpenPlatformService::buildApplication($componentInfo);
+        $openPlatform = WechatOpenPlatformService::buildApplication($componentInfo);
         myLog("wx-xiaoxi")->info('-------开始处理---'.get_date());
-        $server = $app->server;
+        $server = $openPlatform->server;
         $message = $server->getMessage();
         myLog("wx-xiaoxi")->info([
             'authorizer_appid' => $authorizer_appid,
@@ -135,15 +137,8 @@ class WechatOpenPlatformController extends CatchController
             'msg' => $message,
         ]);
         $refreshToken = WechatOpenPlatformService::getRefreshToken($authorizer_appid,$component_appid);
-        $server = $app->officialAccount($authorizer_appid, $refreshToken);
-        // $server->addMessageListener('text', function($message) {
-        //       myLog("wx-xiaoxi")->info('----文本消息---');
-        //     if ($message->Content == "pk"){
-        //         return  $message->FromUserName;
-        //     }
-        // });
-
-        $server->server->push(function ($message) use($authorizer_appid,$component_appid) {
+        $app = $openPlatform->officialAccount($authorizer_appid, $refreshToken);
+        $app->server->push(function ($message) use($authorizer_appid,$component_appid) {
             myLog("wx-xiaoxi")->info("----文本消息---");
             myLog("wx-xiaoxi")->info("体消息:");
             myLog("wx-xiaoxi")->info($message);
@@ -151,6 +146,7 @@ class WechatOpenPlatformController extends CatchController
         });
 
         myLog("wx-xiaoxi")->info('-------结束处理---'.get_date());
-        return $server->serve();
+
+        return $app->server->serve()->send();
     }
 }