diff --git a/app/wechat/service/WechatService.php b/app/wechat/service/WechatService.php index 81636c7cd..e4f5fd0a6 100644 --- a/app/wechat/service/WechatService.php +++ b/app/wechat/service/WechatService.php @@ -110,20 +110,11 @@ class WechatService extends Service [$appid, $appkey] = [sysconf('wechat.thr_appid'), sysconf('wechat.thr_appkey')]; $data = ['class' => $name, 'appid' => $appid, 'time' => time(), 'nostr' => uniqid()]; $data['sign'] = md5("{$data['class']}#{$appid}#{$appkey}#{$data['time']}#{$data['nostr']}"); + // 创建远程连接,默认使用 JSON RPC 方式 $token = enbase64url(json_encode($data, JSON_UNESCAPED_UNICODE)); - $location = "https://open.cuci.cc/service/api.client/_TYPE_?not_init_session=1&token={$token}"; - if (class_exists('Yar_Client')) { - $client = new \Yar_Client(str_replace('_TYPE_', 'yar', $location)); - } else { - $client = new JsonRpcClient(str_replace('_TYPE_', 'jsonrpc', $location)); - } - try { - $exception = new \think\admin\Exception($client->getMessage(), $client->getCode()); - } catch (\Exception $exception) { - $exception = null; - } - if ($exception instanceof \Exception) { - throw $exception; + $client = new JsonRpcClient("https://open.cuci.cc/service/api.client/jsonrpc?not_init_session=1&token={$token}"); + if (is_numeric(stripos($client->__call('_get_class_name_', []), 'Exception'))) { + throw new \think\admin\Exception($client->getMessage(), $client->getCode()); } return $client; } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index d4ffa7a25..903423327 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -853,12 +853,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "b36df3ae241b81fe15f4c155fbfba5aab2431970" + "reference": "b77d3be5faf647d05827c831a069509175126d13" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/b36df3ae241b81fe15f4c155fbfba5aab2431970", - "reference": "b36df3ae241b81fe15f4c155fbfba5aab2431970", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/b77d3be5faf647d05827c831a069509175126d13", + "reference": "b77d3be5faf647d05827c831a069509175126d13", "shasum": "", "mirrors": [ { @@ -875,7 +875,7 @@ "ext-mbstring": "*", "topthink/framework": "^6.0" }, - "time": "2021-06-23T06:30:26+00:00", + "time": "2021-06-25T04:07:35+00:00", "default-branch": true, "type": "library", "extra": { diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 5dafb072f..b82e76b00 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -5,7 +5,7 @@ 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '435de923eecb411bc7a10fb8dab55122b87d5466', + 'reference' => '04d0cd8563af49737965f1567d8d569e800a9eeb', 'name' => 'zoujingli/thinkadmin', 'dev' => false, ), @@ -144,7 +144,7 @@ 'aliases' => array( 0 => '9999999-dev', ), - 'reference' => 'b36df3ae241b81fe15f4c155fbfba5aab2431970', + 'reference' => 'b77d3be5faf647d05827c831a069509175126d13', 'dev_requirement' => false, ), 'zoujingli/thinkadmin' => array( @@ -153,7 +153,7 @@ 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '435de923eecb411bc7a10fb8dab55122b87d5466', + 'reference' => '04d0cd8563af49737965f1567d8d569e800a9eeb', 'dev_requirement' => false, ), 'zoujingli/wechat-developer' => array( diff --git a/vendor/services.php b/vendor/services.php index 2c7355f28..74478d0d6 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\admin\\Library', diff --git a/vendor/zoujingli/think-library/src/extend/JsonRpcClient.php b/vendor/zoujingli/think-library/src/extend/JsonRpcClient.php index 2e7b71be2..8c365d753 100644 --- a/vendor/zoujingli/think-library/src/extend/JsonRpcClient.php +++ b/vendor/zoujingli/think-library/src/extend/JsonRpcClient.php @@ -55,7 +55,7 @@ class JsonRpcClient * @return mixed * @throws Exception */ - public function __call(string $method, array $params) + public function __call(string $method, array $params = []) { // Performs the HTTP POST $options = [ diff --git a/vendor/zoujingli/think-library/src/extend/JsonRpcServer.php b/vendor/zoujingli/think-library/src/extend/JsonRpcServer.php index a0802379d..45330a469 100644 --- a/vendor/zoujingli/think-library/src/extend/JsonRpcServer.php +++ b/vendor/zoujingli/think-library/src/extend/JsonRpcServer.php @@ -75,8 +75,10 @@ class JsonRpcServer $error = ['code' => '-32600', 'message' => '无效的请求', 'meaning' => '发送的JSON不是一个有效的请求对象']; $response = ['jsonrpc' => '2.0', 'id' => $request['id'] ?? '0', 'result' => null, 'error' => $error]; } else try { - // Executes the task on local object - if (method_exists($object, $request['method'])) { + if (strtolower($request['method']) === '_get_class_name_') { + $response = ['jsonrpc' => '2.0', 'id' => $request['id'], 'result' => get_class($object), 'error' => null]; + } elseif (method_exists($object, $request['method'])) { + // Executes the task on local object $result = call_user_func_array([$object, $request['method']], $request['params']); $response = ['jsonrpc' => '2.0', 'id' => $request['id'], 'result' => $result, 'error' => null]; } else { @@ -102,6 +104,7 @@ class JsonRpcServer $object = new ReflectionClass($object); echo "