diff --git a/app/Services/Social/TikTokCreatorInfo.php b/app/Services/Social/TikTokCreatorInfo.php index ce058674..71ce1a4d 100644 --- a/app/Services/Social/TikTokCreatorInfo.php +++ b/app/Services/Social/TikTokCreatorInfo.php @@ -65,7 +65,8 @@ private function fetchFresh(SocialAccount $account): array $this->accessToken = $account->access_token; $response = $this->getHttpClient() - ->post("{$this->baseUrl}/post/publish/creator_info/query/", []); + ->withBody('{}', 'application/json; charset=UTF-8') + ->post("{$this->baseUrl}/post/publish/creator_info/query/"); if ($response->failed()) { Log::warning('TikTok creator_info query failed', [ diff --git a/tests/Feature/Services/Social/TikTokCreatorInfoTest.php b/tests/Feature/Services/Social/TikTokCreatorInfoTest.php index f12bed08..d25edfb7 100644 --- a/tests/Feature/Services/Social/TikTokCreatorInfoTest.php +++ b/tests/Feature/Services/Social/TikTokCreatorInfoTest.php @@ -49,6 +49,18 @@ ->and($info['max_video_post_duration_sec'])->toBe(600); }); +test('it sends an empty json object as the request body', function () { + Http::fake([ + $this->api.'/post/publish/creator_info/query/' => Http::response(['data' => []], 200), + ]); + + $this->service->fetch($this->account); + + Http::assertSent(function ($request) { + return $request->body() === '{}'; + }); +}); + test('it returns an empty payload when the api fails', function () { Http::fake([ $this->api.'/post/publish/creator_info/query/' => Http::response(['error' => 'unauthorized'], 401),