getMessage()}"; } // 验证微信配置信息 $config = $this->app->db->name('WechatServiceConfig')->where(['authorizer_appid' => $appid])->find(); if (empty($config) || empty($config['appuri'])) { sysoplog('微信接口', $message = "微信{$appid}授权配置验证无效"); return $message; } try { list($data, $openid) = [$wechat->getReceive(), $wechat->getOpenid()]; if (isset($data['EventKey']) && is_object($data['EventKey'])) $data['EventKey'] = (array)$data['EventKey']; $input = ['openid' => $openid, 'appid' => $appid, 'receive' => serialize($data), 'encrypt' => intval($wechat->isEncrypt())]; if (is_string($result = http_post($config['appuri'], $input, ['timeout' => 30]))) { if (is_array($json = json_decode($result, true))) { return $wechat->reply($json, true, $wechat->isEncrypt()); } else { return $result; } } } catch (\Exception $exception) { sysoplog('微信接口', "微信{$appid}接口调用异常,{$exception->getMessage()}"); } return 'success'; } }