feat: social video uploads + hero page video + TikTok content
Hero page:
- Replace GIF with squaremcp-hero-loop.mp4 (autoplay, muted, loop)
- Update styles, scripts, tests, Dockerfile, baselines
- Deployed and verified
Social video uploads:
- Twitter/X: uploadVideoAndTweet via v1.1 media/upload + v2 tweets
- Facebook: createVideoPost via Graph API /{pageId}/videos
- Instagram: createReel via Graph API (container → poll → publish)
- TikTok: REST endpoints + OpenAPI schema for video upload
Marketing:
- TikTok content prompts, scripts, and posting schedule
Note: Remotion not mentioned in any user-facing content
This commit is contained in:
@@ -116,11 +116,11 @@ export async function getMedia(
|
||||
}));
|
||||
}
|
||||
|
||||
export async function createPost(
|
||||
export async function createImagePost(
|
||||
args: { image_url: string; caption?: string; account?: string },
|
||||
customer?: Customer
|
||||
): Promise<{ success: boolean; media_id: string }> {
|
||||
const audit = customer ? createToolAudit(customer.id, 'instagram:createPost') : null;
|
||||
const audit = customer ? createToolAudit(customer.id, 'instagram:createImagePost') : null;
|
||||
const auditArgs = { image_url: args.image_url };
|
||||
const { accessToken, businessAccountId } = await resolveCreds(args, customer);
|
||||
|
||||
@@ -129,7 +129,7 @@ export async function createPost(
|
||||
`/${businessAccountId}/media`,
|
||||
accessToken,
|
||||
'POST',
|
||||
{ image_url: args.image_url, caption: args.caption, media_type: 'REELS' }
|
||||
{ image_url: args.image_url, caption: args.caption }
|
||||
);
|
||||
|
||||
const creationId = container.id;
|
||||
@@ -150,3 +150,65 @@ export async function createPost(
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
export async function createReel(
|
||||
args: { video_url: string; caption?: string; account?: string },
|
||||
customer?: Customer
|
||||
): Promise<{ success: boolean; media_id: string }> {
|
||||
const audit = customer ? createToolAudit(customer.id, 'instagram:createReel') : null;
|
||||
const auditArgs = { video_url: args.video_url };
|
||||
const { accessToken, businessAccountId } = await resolveCreds(args, customer);
|
||||
|
||||
try {
|
||||
const container = await instagramRequest(
|
||||
`/${businessAccountId}/media`,
|
||||
accessToken,
|
||||
'POST',
|
||||
{ media_type: 'REELS', video_url: args.video_url, caption: args.caption, share_to_feed: true }
|
||||
);
|
||||
|
||||
const creationId = container.id;
|
||||
if (!creationId) throw new Error('Failed to create Instagram media container');
|
||||
|
||||
// Poll for container status
|
||||
let retries = 0;
|
||||
const maxRetries = 10;
|
||||
const delayMs = 5000;
|
||||
|
||||
while (retries < maxRetries) {
|
||||
const statusData = await instagramRequest(
|
||||
`/${creationId}?fields=status_code`,
|
||||
accessToken
|
||||
);
|
||||
|
||||
if (statusData.status_code === 'FINISHED') {
|
||||
break;
|
||||
}
|
||||
|
||||
if (statusData.status_code === 'ERROR') {
|
||||
throw new Error('Instagram media container processing failed');
|
||||
}
|
||||
|
||||
retries++;
|
||||
if (retries >= maxRetries) {
|
||||
throw new Error('Instagram media container polling timed out');
|
||||
}
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
||||
}
|
||||
|
||||
const publish = await instagramRequest(
|
||||
`/${businessAccountId}/media_publish`,
|
||||
accessToken,
|
||||
'POST',
|
||||
{ creation_id: creationId }
|
||||
);
|
||||
|
||||
const result = { success: true, media_id: publish.id };
|
||||
if (audit) await audit.success(auditArgs);
|
||||
return result;
|
||||
} catch (err) {
|
||||
if (audit) await audit.error(auditArgs, String(err));
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user