fix: use publicaly_available_post_id from TikTok status to build video URL
This commit is contained in:
parent
326648d4f9
commit
c5c36a8aba
1 changed files with 13 additions and 7 deletions
|
|
@ -154,11 +154,12 @@ private function publishVideo(PostPlatform $postPlatform, $media, ?string $conte
|
|||
}
|
||||
|
||||
// Wait for processing and get final status
|
||||
$this->waitForPublishStatus($publishId);
|
||||
$statusData = $this->waitForPublishStatus($publishId);
|
||||
$postId = data_get($statusData, 'publicaly_available_post_id.0');
|
||||
|
||||
return [
|
||||
'id' => $publishId,
|
||||
'url' => $this->buildTikTokUrl($postPlatform->socialAccount),
|
||||
'id' => $postId ?? $publishId,
|
||||
'url' => $this->buildTikTokUrl($postPlatform->socialAccount, $postId),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -215,11 +216,12 @@ private function publishPhotos(PostPlatform $postPlatform, $mediaCollection, ?st
|
|||
}
|
||||
|
||||
// Wait for processing and get final status
|
||||
$this->waitForPublishStatus($publishId);
|
||||
$statusData = $this->waitForPublishStatus($publishId);
|
||||
$postId = data_get($statusData, 'publicaly_available_post_id.0');
|
||||
|
||||
return [
|
||||
'id' => $publishId,
|
||||
'url' => $this->buildTikTokUrl($postPlatform->socialAccount),
|
||||
'id' => $postId ?? $publishId,
|
||||
'url' => $this->buildTikTokUrl($postPlatform->socialAccount, $postId),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -262,10 +264,14 @@ private function waitForPublishStatus(string $publishId, int $maxAttempts = 20):
|
|||
return ['publish_id' => $publishId];
|
||||
}
|
||||
|
||||
private function buildTikTokUrl(SocialAccount $account): ?string
|
||||
private function buildTikTokUrl(SocialAccount $account, ?string $postId = null): ?string
|
||||
{
|
||||
$username = $account->username;
|
||||
|
||||
if ($username && $postId) {
|
||||
return "https://www.tiktok.com/@{$username}/video/{$postId}";
|
||||
}
|
||||
|
||||
if ($username) {
|
||||
return "https://www.tiktok.com/@{$username}";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue