diff --git a/app/Http/Clients/TikTokHttpClient.php b/app/Http/Clients/TikTokHttpClient.php index 3f928b3..60a3a00 100644 --- a/app/Http/Clients/TikTokHttpClient.php +++ b/app/Http/Clients/TikTokHttpClient.php @@ -11,9 +11,10 @@ class TikTokHttpClient protected array $config; protected Client $client; - public function __construct() + public function __construct(Client $client) { $this->config = config('services.tiktok'); + $this->client = $client; } public function getAccessToken(string $code) diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 940269c..5cf5c73 100755 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -144,7 +144,7 @@ public function loginViaMagicLink(Request $request, LocationService $locationSer * * @throws GuzzleException */ - public function tikTokHandleCallback(Request $request, TikTokHttpClient $client, UserService $service) + public function tikTokHandleCallback(Request $request, TikTokHttpClient $httpClient, UserService $service) { $code = $request->get('code'); $errCode = $request->get('errCode'); @@ -154,7 +154,7 @@ public function tikTokHandleCallback(Request $request, TikTokHttpClient $client, } try { - $decoded = $client->getAccessToken($code); + $decoded = $httpClient->getAccessToken($code); $message = Arr::get($decoded, 'message'); $open_id = Arr::get($decoded, 'data.open_id'); $access_token = Arr::get($decoded, 'data.access_token'); @@ -163,7 +163,7 @@ public function tikTokHandleCallback(Request $request, TikTokHttpClient $client, throw new \Exception(json_encode($decoded)); } - $userInfo = $client->getUserInfo($open_id, $access_token); + $userInfo = $httpClient->getUserInfo($open_id, $access_token); if (!empty($userInfo['data']['user'])) { $open_id = Arr::get($userInfo, 'data.user.open_id');