aesKey = $component['aes_key']; $this->authToken = $component['auth_token']; } /* * 获取验证票据 ComponentVerifyTicket * */ public function getVerifyTicket(Request $request) { $sVerifyMsgSig = $request->input('msg_signature'); $sVerifyTimeStamp = $request->input('timestamp'); $sVerifyNonce = $request->input('nonce'); if($request->isMethod('get')){ // 初步校验回调链接合法性 $sVerifyEchoStr = $request->input('echostr'); $sEchoStr = ""; # 需要返回的明文 $crypt = new \WXBizMsgCrypt($this->authToken, $this->aesKey, $this->corpid); $errCode = $crypt->VerifyURL($sVerifyMsgSig, $sVerifyTimeStamp, $sVerifyNonce, $sVerifyEchoStr, $sEchoStr); if ($errCode == 0) { echo $sEchoStr; } else { Log::logInfo('Errcode:'.$errCode, [], 'verifyTicketGetFail'); } } elseif ($request->isMethod('post')){ $requestMsg = file_get_contents('php://input'); $sMsg = ""; # 需要返回的明文 $crypt = new \WXBizMsgCrypt($this->authToken, $this->aesKey, $this->suiteId); $errCode = $crypt->DecryptMsg($sVerifyMsgSig, $sVerifyTimeStamp, $sVerifyNonce, $requestMsg, $sMsg); // Log::logInfo('解密后内容'. $sMsg, [], '0316'); echo 'success'; // if($errCode == 0) { $result = MsgService::responseCommand($sMsg); // if($result) { // echo 'success'; // } // exit; // } else { // Log::logError('verifyTicket获取失败', ['errCode' => $errCode], 'verifyTicketPostFail'); // } } } /** * 获取微信广告的授权二维码 * @param Request $request */ public function getWxadAuthCode(Request $request) { $url = 'https://developers.e.qq.com/oauth/authorize?'; $wxadConfig = config('wxad'); $sysGroupId = $request->input('sys_group_id'); $userId = $request->input('admin_id'); // 用户 $user = Users::query()->find($userId); $sysGroupId = Users::query() ->where('enable', 1) ->where(function ($query) use($user, $userId, $sysGroupId) { if($user->is_system_admin) { $query->where('group_admin_id', $sysGroupId); } else { $query->where('id', $userId); } }) ->value('group_admin_id'); $query = http_build_query([ 'client_id' => $wxadConfig['client_id'], 'state' => $sysGroupId, // 'state' => 'novel', 'scope' => '', 'redirect_uri' => $wxadConfig['redirect_uri'], 'account_type' => "ACCOUNT_TYPE_WECHAT", 'account_display_number' => 2 ]); Log::logInfo('getWxadAuthCode', [ 'params' => $request->all(), 'url' => $url.$query ], 'interface'); echo $url.$query; } }