FBINSTA Platform Integration Guide
✅ Implementation Complete
A unified "FBINSTA" platform has been successfully integrated into the social posts UI, enabling simultaneous publishing to both Facebook and Instagram.
🎯 What Was Built
1. Backend API Endpoint
Location: src/api/admin/socials/publish-both/route.ts
Endpoint: POST /admin/socials/publish-both
Features:
- Validates post and platform configuration
- Extracts Facebook Page ID and Instagram User ID from post metadata
- Uses ContentPublishingService to publish to both platforms
- Updates post with results from both platforms
- Stores Facebook post ID and Instagram permalink in insights
Request:
{
"post_id": "post_123"
}
Response:
{
"success": true,
"post": { /* updated post object */ },
"results": {
"facebook": {
"platform": "facebook",
"success": true,
"postId": "fb_123"
},
"instagram": {
"platform": "instagram",
"success": true,
"postId": "ig_456",
"permalink": "https://www.instagram.com/p/abc123/"
}
}
}
2. React Hook
Location: src/admin/hooks/api/social-posts.ts
Hook: usePublishToBothPlatforms()
Features:
- Calls the publish-both endpoint
- Shows success toast for both platforms
- Invalidates query cache to refresh UI
- Handles errors gracefully
Usage:
const { mutate: publishToBoth, isPending } = usePublishToBothPlatforms()
publishToBoth({ post_id: "post_123" })
3. Create Post UI
Location: src/admin/components/social-posts/create-social-post-component.tsx
Features:
- Detects FBINSTA platform
- Shows unified form with:
- Post type selector (currently photo only)
- Facebook Page selector
- Instagram Account selector
- Message/Caption field
- Media picker
- Auto-publish toggle
- Validates both page_id and ig_user_id are selected
- Stores both IDs in post metadata
4. Post Detail UI
Location: src/admin/components/social-posts/social-post-general-section.tsx
Features:
- Detects FBINSTA platform
- Shows "Publish to Both Platforms" button instead of "Publish now"
- Displays both Facebook and Instagram post URLs after publishing
- Extracts URLs from post insights
📋 How to Use
Step 1: Create FBINSTA Platform
- Go to Settings → Social Platforms
- Click Create
- Enter:
- Name:
FBINSTA(or "Facebook & Instagram") - Description: "Unified Facebook and Instagram publishing"
- URL: (optional)
- Name:
- Click Save
Step 2: Configure OAuth
- Open the FBINSTA platform detail page
- Click Authenticate or Connect
- Complete Facebook OAuth flow
- Grant permissions:
pages_show_listpages_manage_postspages_read_engagement
- System will automatically fetch:
- Facebook Pages you manage
- Instagram Business accounts linked to those pages
Important: The OAuth token and account lists are stored in platform.api_config:
{
"access_token": "user_token_here",
"metadata": {
"pages": [
{ "id": "123", "name": "My Page" }
],
"ig_accounts": [
{ "id": "456", "username": "myaccount" }
]
}
}
Step 3: Create a Post
- Go to Social Posts
- Click Create
- Fill in:
- Name: "Summer Sale Announcement"
- Platform: Select "FBINSTA"
- The FBINSTA section will appear with:
- Post Type: Photo (Both platforms)
- Facebook Page: Select your page
- Instagram Account: Select your IG account
- Message/Caption: Enter your text
- Media: Upload one image
- Auto publish: Toggle if you want immediate publishing
- Click Save
Step 4: Publish
Option A: Auto-publish (Immediate)
- If you enabled "Auto publish" during creation, the post publishes immediately to both platforms
Option B: Manual publish
- Open the post detail page
- Click "Publish to Both Platforms" button
- Wait for confirmation
- Both Facebook and Instagram URLs will appear in the post details
🔍 Data Flow
1. User creates FBINSTA platform
↓
2. OAuth stores token + pages + IG accounts in api_config
↓
3. User creates post with FBINSTA platform
- Selects page_id and ig_user_id
- Stores in post.metadata
↓
4. User clicks "Publish to Both Platforms"
↓
5. Backend workflow:
- Loads post
- Gets platform.api_config.access_token
- Gets post.metadata.page_id and ig_user_id
- Calls ContentPublishingService.publishContent()
- Publishes to Facebook (direct)
- Publishes to Instagram (container → publish)
↓
6. Updates post:
- status: "posted"
- post_url: Facebook URL
- insights: {
facebook_post_id: "123",
instagram_media_id: "456",
instagram_permalink: "https://...",
publish_results: [...]
}
📊 Post Metadata Structure
After creation:
{
"page_id": "facebook_page_123",
"ig_user_id": "instagram_user_456",
"auto_publish": true
}
After publishing:
{
"page_id": "facebook_page_123",
"ig_user_id": "instagram_user_456",
"auto_publish": true
}
Post insights after publishing:
{
"facebook_post_id": "fb_post_123",
"instagram_media_id": "ig_media_456",
"instagram_permalink": "https://www.instagram.com/p/abc123/",
"published_at": "2025-01-01T12:00:00Z",
"publish_results": [
{
"platform": "facebook",
"success": true,
"postId": "fb_post_123"
},
{
"platform": "instagram",
"success": true,
"postId": "ig_media_456",
"permalink": "https://www.instagram.com/p/abc123/"
}
]
}
⚠️ Current Limitations
1. Content Type Support
- ✅ Photo posts: Fully supported on both platforms
- ❌ Video/Reel posts: Not yet supported for dual publishing
- ❌ Text posts: Instagram requires media, so not supported
Workaround: Create separate posts for video content on each platform.
2. Platform Requirements
Facebook:
- Must have manage permissions for the Page
- Page must be active
Instagram:
- Must be a Business or Creator account
- Must be linked to a Facebook Page
- Account must be active
3. Rate Limits
- Facebook: 200 API calls per hour per user
- Instagram: 25 posts per day per account
🔧 Troubleshooting
Issue: "No access token found"
Solution: Re-authenticate the FBINSTA platform via OAuth
Issue: "No Facebook page_id found"
Solution: Ensure you selected a Facebook Page when creating the post
Issue: "No Instagram ig_user_id found"
Solution: Ensure you selected an Instagram account when creating the post
Issue: "Instagram account not found"
Solution:
- Verify the Instagram account is linked to the Facebook Page
- Re-authenticate the platform to refresh the account list
Issue: "Text-only posts not supported"
Solution: Add at least one image to the post
Issue: Platform not showing in dropdown
Solution: Create a new Social Platform with name "FBINSTA" or "Facebook & Instagram"