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 <paulo@castellanos.llc>
This commit is contained in:
parent
2248d01edc
commit
e52d1d7b25
2 changed files with 14 additions and 1 deletions
|
|
@ -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', [
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Reference in a new issue