# Meta (Facebook & Instagram) API Setup Guide This guide provides step-by-step instructions for setting up Meta Graph API integration for managing Facebook Pages and Instagram Business accounts. --- ## Table of Contents 1. [Overview](#overview) 2. [Prerequisites](#prerequisites) 3. [Meta for Developers Setup](#meta-for-developers-setup) 4. [Environment Configuration](#environment-configuration) 5. [OAuth Redirect URI Configuration](#oauth-redirect-uri-configuration) 6. [Permissions & Scopes](#permissions--scopes) 7. [Webhook Configuration](#webhook-configuration) 8. [Development vs Production](#development-vs-production) 9. [Troubleshooting](#troubleshooting) --- ## Overview **API Version:** Graph API v24.0 **Base URL:** `https://graph.facebook.com/v24.0` **Auth URL:** `https://www.facebook.com/v24.0/dialog/oauth` ### Features Supported - **Facebook Pages:** - Fetch page posts - Read comments on posts - Reply to comments as the Page - **Instagram Business:** - Fetch Instagram media posts - Read comments on posts - Reply to comments (with nesting limitations) ### How It Works 1. User authenticates with Facebook 2. App discovers all Facebook Pages the user manages 3. For each Page, app also discovers linked Instagram Business accounts 4. Page Access Tokens are permanent (don't expire if app is active) --- ## Prerequisites - A Facebook account with admin access to at least one Facebook Page - An Instagram Business Account linked to your Facebook Page - Access to [Meta for Developers](https://developers.facebook.com/) - HTTPS-enabled server for production ### Linking Instagram to Facebook Page 1. Go to your Facebook Page settings 2. Navigate to **Instagram** → **Connect Account** 3. Log in to your Instagram Business account 4. Authorize the connection --- ## Meta for Developers Setup ### Step 1: Create a Meta App 1. Navigate to [Meta for Developers](https://developers.facebook.com/apps/) 2. Click **"Create App"** 3. Select **"Business"** as the app type 4. Fill in the details: - **App Name:** Your application name (e.g., "PX360 Social Manager") - **App Contact Email:** Your contact email - **Business Account:** Select your business (if applicable) 5. Click **"Create App"** 6. Complete security verification if prompted ### Step 2: Configure Basic Settings 1. Go to **"Settings"** → **"Basic"** 2. Fill in required fields: - **Privacy Policy URL:** Your privacy policy URL - **User Data Deletion:** Provide deletion instructions or URL - **Category:** Select "Business Tools" 3. Add **App Domains** (your application's domain) 4. Click **"Save Changes"** ### Step 3: Add Facebook Login Product 1. Go to **"Add Products"** (left sidebar) 2. Find **"Facebook Login"** and click **"Set Up"** 3. Select **"Web"** as platform 4. Enter your site URL 5. Configure OAuth settings (see Redirect URI section below) ### Step 4: Get App Credentials 1. Go to **"Settings"** → **"Basic"** 2. Copy the following: - **App ID** → This is your `META_APP_ID` - **App Secret** → Click "Show" → This is your `META_APP_SECRET` > ⚠️ **Important:** Never expose your App Secret in client-side code.