From 0c32ce0256177e599e8f7f6bb02e94a22518245a Mon Sep 17 00:00:00 2001 From: Lkeme <19500576+lkeme@users.noreply.github.com> Date: Wed, 31 Aug 2022 17:23:50 +0800 Subject: [PATCH] [fix] NotLoginError fixed#184 --- plugin/MainSite/MainSite.php | 15 ++++++++++----- src/Api/Video/ApiShare.php | 4 +--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/plugin/MainSite/MainSite.php b/plugin/MainSite/MainSite.php index 4824036..4383162 100644 --- a/plugin/MainSite/MainSite.php +++ b/plugin/MainSite/MainSite.php @@ -111,15 +111,20 @@ class MainSite extends BasePlugin * 投币 * @param string $aid * @return void + * @throws NoLoginException */ protected function reward(string $aid): void { $response = ApiCoin::coin($aid); // - if ($response['code']) { - Log::warning("主站任务: $aid 投币失败 {$response['code']} -> {$response['message']}"); - } else { - Log::notice("主站任务: $aid 投币成功"); + switch ($response['code']) { + case -101: + throw new NoLoginException($response['message']); + case 0: + Log::notice("主站任务: $aid 投币成功"); + break; + default: + Log::warning("主站任务: $aid 投币失败 {$response['code']} -> {$response['message']}"); } } @@ -280,7 +285,7 @@ class MainSite extends BasePlugin // $response = ApiShare::share($aid); switch ($response['code']) { - case 137004: + case -101: throw new NoLoginException($response['message']); case 0: Log::notice("主站任务: $aid 分享成功"); diff --git a/src/Api/Video/ApiShare.php b/src/Api/Video/ApiShare.php index a7fca7e..a476255 100644 --- a/src/Api/Video/ApiShare.php +++ b/src/Api/Video/ApiShare.php @@ -25,7 +25,6 @@ class ApiShare /** * 分享视频 * @param string $aid - * @param string $cid * @return array */ public static function share(string $aid): array @@ -37,7 +36,6 @@ class ApiShare // $payload = [ 'aid' => $aid, - 'jsonp' => "jsonp", 'csrf' => $user['csrf'], ]; $headers = [ @@ -48,4 +46,4 @@ class ApiShare return Request::postJson(true, 'pc', $url, $payload, $headers); } -} \ No newline at end of file +}