|
@@ -12,6 +12,7 @@ use Modules\Channel\Services\WechatOpenPlatform\WechatOpenPlatformService;
|
|
|
use Modules\Common\Errors\Errors;
|
|
|
use Modules\Common\Exceptions\CommonBusinessException;
|
|
|
use Modules\User\Http\Controllers\UserTrait;
|
|
|
+use Modules\WechatPlatform\Services\WechatCommonService;
|
|
|
|
|
|
class WechatOpenPlatformController extends CatchController
|
|
|
{
|
|
@@ -94,7 +95,7 @@ class WechatOpenPlatformController extends CatchController
|
|
|
'nick_name' => $gzhBaseInfo['authorizer_info']['nick_name'],
|
|
|
]);
|
|
|
|
|
|
- return view('wechat.openPlatform.authSuccess')->with('url', sprintf('%s/#/user/advertiser', config('app.url')));
|
|
|
+ return view('wechat.openPlatform.authSuccess')->with('url', sprintf('%s/#/user/advertiser',config('app.url')));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -124,27 +125,32 @@ class WechatOpenPlatformController extends CatchController
|
|
|
|
|
|
$componentInfo = WechatOpenPlatformService::getComponentInfoByAppid($component_appid);
|
|
|
$app = WechatOpenPlatformService::buildApplication($componentInfo);
|
|
|
- myLog("wx-xiaoxi")->info('-------开始处理---' . get_date());
|
|
|
- $server = $app->getServer();
|
|
|
- $message = $server->getDecryptedMessage();
|
|
|
+ myLog("wx-xiaoxi")->info('-------开始处理---'.get_date());
|
|
|
+ $server = $app->server;
|
|
|
+ $message = $server->getMessage();
|
|
|
myLog("wx-xiaoxi")->info([
|
|
|
'authorizer_appid' => $authorizer_appid,
|
|
|
'component_appid' => $component_appid,
|
|
|
'param' => $request->all(),
|
|
|
'msg' => $message,
|
|
|
]);
|
|
|
- $refreshToken = WechatOpenPlatformService::getRefreshToken($authorizer_appid, $component_appid);
|
|
|
- $server = $app->getOfficialAccountWithRefreshToken($authorizer_appid, $refreshToken)->getServer();
|
|
|
- $server->addMessageListener('text', function ($message) {
|
|
|
- myLog("wx-xiaoxi")->info('----文本消息---');
|
|
|
- if ($message->Content == "pk") {
|
|
|
- return $message->FromUserName;
|
|
|
- }
|
|
|
- });
|
|
|
+ $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->addEventListener('subscribe', function () {
|
|
|
+ $server->server->push(function ($message) use($authorizer_appid,$component_appid) {
|
|
|
+ myLog("wx-xiaoxi")->info("----文本消息---");
|
|
|
+ myLog("wx-xiaoxi")->info("体消息:");
|
|
|
+ myLog("wx-xiaoxi")->info($message);
|
|
|
+ return WechatCommonService::handleMessage($authorizer_appid,$message);
|
|
|
});
|
|
|
- myLog("wx-xiaoxi")->info('-------结束处理---' . get_date());
|
|
|
+
|
|
|
+ myLog("wx-xiaoxi")->info('-------结束处理---'.get_date());
|
|
|
return $server->serve();
|
|
|
}
|
|
|
}
|