From e52d1d7b258d46e199ed2f5d97de89a370f5f5ed Mon Sep 17 00:00:00 2001 From: Mohammed Almuhanna <19901807+Goo6i@users.noreply.github.com> Date: Thu, 6 Aug 2026 00:39:32 +0300 Subject: [PATCH] fix(tiktok): send an empty JSON object to creator_info (#224) Laravel serialises the empty array argument to `[]`. TikTok's creator_info endpoint expects an object and rejects the array with invalid_params, so every query failed and the service returned emptyPayload(), leaving the composer with no creator data. Co-authored-by: Paulo Castellano --- app/Services/Social/TikTokCreatorInfo.php | 3 ++- .../Services/Social/TikTokCreatorInfoTest.php | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) 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),