diff --git a/src/Oauth/Oauth.php b/src/Oauth/Oauth.php index 9102952..d737f79 100644 --- a/src/Oauth/Oauth.php +++ b/src/Oauth/Oauth.php @@ -19,13 +19,11 @@ class Oauth extends KwaixiaodianApi public function accessToken($code, string $grant_type = 'code'): array { $config = $this->getConfig(); - $response = $this->getHttpClient()->request('GET', $this->getBaseUri() . 'oauth2/access_token', [ - 'query' => [ - 'app_id' => $config['app_key'], - 'app_secret' => $config['app_secret'], - 'grant_type' => $grant_type, - 'code' => $code, - ], + $response = $this->getHttpClient()->get($this->getBaseUri() . 'oauth2/access_token', [ + 'app_id' => $config['app_key'], + 'app_secret' => $config['app_secret'], + 'grant_type' => $grant_type, + 'code' => $code, ]); return Utils::jsonResponseToArray($response); } @@ -38,13 +36,11 @@ public function accessToken($code, string $grant_type = 'code'): array public function refreshToken($refresh_token): array { $config = $this->getConfig(); - $response = $this->getHttpClient()->request('GET', $this->getBaseUri() . 'oauth2/refresh_token', [ - 'query' => [ - 'app_id' => $config['app_key'], - 'app_secret' => $config['app_secret'], - 'grant_type' => 'refresh_token', - 'refresh_token' => $refresh_token, - ], + $response = $this->getHttpClient()->post($this->getBaseUri() . 'oauth2/refresh_token', [ + 'grant_type' => 'refresh_token', + 'refresh_token' => $refresh_token, + 'app_id' => $config['app_key'], + 'app_secret' => $config['app_secret'], ]); return Utils::jsonResponseToArray($response); } diff --git a/tests/Api/DistributionTest.php b/tests/Api/DistributionTest.php index 0dbb0d5..4ea700b 100644 --- a/tests/Api/DistributionTest.php +++ b/tests/Api/DistributionTest.php @@ -38,6 +38,7 @@ public function testOpenDistributionCpsKwaimoneyLinkCreate() 'page' => 1, 'pageSize' => 1, ]); + $this->isSuccessResponse($pidListResult); $pid = $pidListResult['data']['cpsPidData'][0]; $itemListResult = $app->distribution->openDistributionCpsKwaimoneySelectionItemList([ @@ -45,6 +46,7 @@ public function testOpenDistributionCpsKwaimoneyLinkCreate() 'pageSize' => 1, 'planType' => 1, ]); + $this->isSuccessResponse($itemListResult); $item = $itemListResult['data']['itemList'][0]; $response = $app->distribution->openDistributionCpsKwaimoneyLinkCreate([