feat: tiktok access token fix
This commit is contained in:
parent
d4300a17ac
commit
35a9b1c4cf
|
|
@ -222,58 +222,51 @@ export class TiktokProvider extends SocialAbstract implements SocialProvider {
|
|||
postDetails: PostDetails<TikTokDto>[],
|
||||
integration: Integration
|
||||
): Promise<PostResponse[]> {
|
||||
try {
|
||||
const [firstPost, ...comments] = postDetails;
|
||||
const [firstPost, ...comments] = postDetails;
|
||||
|
||||
const {
|
||||
data: { publish_id },
|
||||
} = await (
|
||||
await this.fetch(
|
||||
'https://open.tiktokapis.com/v2/post/publish/video/init/',
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
post_info: {
|
||||
title: firstPost.message,
|
||||
privacy_level: firstPost.settings.privacy_level,
|
||||
disable_duet: !firstPost.settings.duet,
|
||||
disable_comment: !firstPost.settings.comment,
|
||||
disable_stitch: !firstPost.settings.stitch,
|
||||
brand_content_toggle: firstPost.settings.brand_content_toggle,
|
||||
brand_organic_toggle: firstPost.settings.brand_organic_toggle,
|
||||
},
|
||||
source_info: {
|
||||
source: 'PULL_FROM_URL',
|
||||
video_url: firstPost?.media?.[0]?.url!,
|
||||
},
|
||||
}),
|
||||
}
|
||||
)
|
||||
).json();
|
||||
|
||||
const { url, id: videoId } = await this.uploadedVideoSuccess(
|
||||
integration.profile!,
|
||||
publish_id,
|
||||
accessToken
|
||||
);
|
||||
|
||||
return [
|
||||
const {
|
||||
data: { publish_id },
|
||||
} = await (
|
||||
await this.fetch(
|
||||
'https://open.tiktokapis.com/v2/post/publish/video/init/',
|
||||
{
|
||||
id: firstPost.id,
|
||||
releaseURL: url,
|
||||
postId: String(videoId),
|
||||
status: 'success',
|
||||
},
|
||||
];
|
||||
} catch (err) {
|
||||
throw new BadBody('titok-error', JSON.stringify(err), {
|
||||
// @ts-ignore
|
||||
postDetails,
|
||||
});
|
||||
}
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
post_info: {
|
||||
title: firstPost.message,
|
||||
privacy_level: firstPost.settings.privacy_level,
|
||||
disable_duet: !firstPost.settings.duet,
|
||||
disable_comment: !firstPost.settings.comment,
|
||||
disable_stitch: !firstPost.settings.stitch,
|
||||
brand_content_toggle: firstPost.settings.brand_content_toggle,
|
||||
brand_organic_toggle: firstPost.settings.brand_organic_toggle,
|
||||
},
|
||||
source_info: {
|
||||
source: 'PULL_FROM_URL',
|
||||
video_url: firstPost?.media?.[0]?.url!,
|
||||
},
|
||||
}),
|
||||
}
|
||||
)
|
||||
).json();
|
||||
|
||||
const { url, id: videoId } = await this.uploadedVideoSuccess(
|
||||
integration.profile!,
|
||||
publish_id,
|
||||
accessToken
|
||||
);
|
||||
|
||||
return [
|
||||
{
|
||||
id: firstPost.id,
|
||||
releaseURL: url,
|
||||
postId: String(videoId),
|
||||
status: 'success',
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue