getConfig()); } else { list($appid, $appkey) = [sysconf('wechat.appid'), sysconf('wechat.appkey')]; $data = ['class' => $name, 'appid' => $appid, 'time' => time(), 'nostr' => uniqid()]; $data['sign'] = md5("{$data['class']}#{$appid}#{$appkey}#{$data['time']}#{$data['nostr']}"); $token = enbase64url(json_encode($data, JSON_UNESCAPED_UNICODE)); if (class_exists('Yar_Client')) { $url = "http://open.cuci.cc/service/api.client/yar?not_init_session=1&token={$token}"; $client = new \Yar_Client($url); } else { $url = "http://open.cuci.cc/service/api.client/soap?not_init_session=1&token={$token}"; $client = new \SoapClient(null, ['location' => $url, 'uri' => "thinkadmin"]); } try { $exception = new \think\Exception($client->getMessage(), $client->getCode()); } catch (\Exception $exception) { $exception = null; } if ($exception instanceof \Exception) { throw $exception; } return $client; } } /** * 获取公众号配置参数 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function getConfig() { return [ 'token' => sysconf('wechat.token'), 'appid' => sysconf('wechat.appid'), 'appsecret' => sysconf('service.appsecret'), 'encodingaeskey' => sysconf('service.encodingaeskey'), 'cache_path' => $this->app->getRuntimePath() . 'wechat', ]; } }