# MTS Social Auto Post - Setup Guide

Complete step-by-step guide to set up Facebook auto-posting for your WordPress site.

---

## Table of Contents

1. [Prerequisites](#prerequisites)
2. [Step 1: Create a Facebook App](#step-1-create-a-facebook-app)
3. [Step 2: Configure App Permissions](#step-2-configure-app-permissions)
4. [Step 3: Create a System User](#step-3-create-a-system-user)
5. [Step 4: Generate Page Access Token](#step-4-generate-page-access-token)
6. [Step 5: Publish Your App](#step-5-publish-your-app)
7. [Step 6: Configure the Plugin](#step-6-configure-the-plugin)
8. [Step 7: Test Your Setup](#step-7-test-your-setup)

---

## Prerequisites

Before you begin, make sure you have:

- [ ] A Facebook Page you manage
- [ ] A Facebook Business Manager account (free to create)
- [ ] Admin access to your WordPress site
- [ ] MTS Social Auto Post plugin installed and activated

---

## Step 1: Create a Facebook App

### 1.1 Go to Facebook Developers

1. Visit [developers.facebook.com](https://developers.facebook.com/)
2. Click **"My Apps"** in the top right
3. Click **"Create App"**

### 1.2 Select App Type

1. Choose **"Business"** as the app type
2. Click **"Next"**

### 1.3 App Details

1. **App Name:** Your app name (e.g., "My Site Auto Post")
2. **App Contact Email:** Your email
3. **Business Account:** Select your Business Manager account
4. Click **"Create App"**

### 1.4 Note Your App ID

After creation, note your **App ID** from the dashboard - you'll need it later.

---

## Step 2: Configure App Permissions

### 2.1 Add Use Case

1. In your app dashboard, click **"Use cases"** in the left sidebar
2. Click **"Add use case"**
3. Select **"Manage everything on your Page"** (or similar page management option)
4. Click **"Confirm"**

### 2.2 Configure Permissions

1. Click on the use case you just added
2. Click **"Customize"** or **"Configure"**
3. Ensure these permissions are enabled:
   - ✅ `pages_show_list`
   - ✅ `pages_read_engagement`
   - ✅ `pages_manage_posts`
4. Save changes

### 2.3 Add Facebook Login for Business

1. In left sidebar, click **"Facebook Login for Business"**
2. Click **"Set Up"** or **"Configure"**
3. Under **Settings**, add your **Valid OAuth Redirect URIs**:
   ```
   https://yourdomain.com/
   ```
4. Save changes

---

## Step 3: Create a System User

System Users are special accounts for API access that don't require a personal Facebook login.

### 3.1 Go to Business Manager

1. Visit [business.facebook.com/settings](https://business.facebook.com/settings)
2. Click **"Users"** in the left sidebar
3. Click **"System users"**

### 3.2 Create System User

1. Click **"Add"**
2. **System User Name:** "API Bot" (or any descriptive name)
3. **System User Role:** Select **"Admin"**
4. Click **"Create System User"**

### 3.3 Assign Assets

1. Click on your new System User
2. Click **"Assign assets"** tab
3. **Add your Page:**
   - Select "Pages"
   - Find your Facebook Page
   - Enable **"Full control"**
   - Click "Save changes"
4. **Add your App:**
   - Select "Apps"
   - Find your Facebook App
   - Enable **"Full control"**
   - Click "Save changes"

---

## Step 4: Generate Page Access Token

### 4.1 Generate System User Token

1. Still on the System User page, click **"Generate new token"**
2. Select your **App** from the dropdown
3. **Token Expiration:** Choose "Never" for permanent tokens (recommended)
4. **Select permissions:**
   - ✅ `pages_show_list`
   - ✅ `pages_read_engagement`
   - ✅ `pages_manage_posts`
5. Click **"Generate token"**
6. **Copy this token** (you won't see it again!)

### 4.2 Get Page Access Token

The System User token identifies as the system user, not your page. We need to extract the Page Token:

1. Go to [Graph API Explorer](https://developers.facebook.com/tools/explorer/)
2. Paste your **System User token** in the Access Token field
3. In the query field, enter: `me/accounts`
4. Click **"Submit"**
5. Find your page in the response:
   ```json
   {
     "data": [
       {
         "access_token": "EAAxxxxxxx...",  ← COPY THIS
         "name": "Your Page Name",
         "id": "123456789"  ← Note your Page ID too
       }
     ]
   }
   ```
6. **Copy the `access_token`** - this is your Page Access Token

### 4.3 Verify the Token

1. In Graph API Explorer, replace the token with the Page Access Token you just copied
2. Query: `me?fields=id,name`
3. Click **"Submit"**
4. ✅ **Correct:** Response shows your Page name
5. ❌ **Wrong:** Response shows your personal name - go back to step 4.2

---

## Step 5: Publish Your App

**Important:** Your app must be Live for full functionality.

### 5.1 Check Requirements

1. In your app dashboard, click **"Publish"** in the left sidebar
2. Review the checklist
3. Complete any missing requirements

### 5.2 Publish

1. Once all requirements are met, click the **"Publish"** button
2. Confirm publication
3. Your app status should change from "In Development" to "Live"

### 5.3 Regenerate Token (Critical!)

**Tokens generated before the app went Live may not work properly.**

1. Go back to Step 4 and regenerate a fresh token
2. Use this new token in your plugin

---

## Step 6: Configure the Plugin

### 6.1 Access Plugin Settings

1. In WordPress admin, go to **Social Auto Post** → **Settings**

### 6.2 Enter Facebook Credentials

Fill in the following fields:

| Field | Value |
|-------|-------|
| **App ID** | Your Facebook App ID (from Step 1) |
| **App Secret** | Found in App Dashboard → Settings → Basic |
| **Page ID** | Your Facebook Page ID (from Step 4) |
| **Page Access Token** | The Page Token you generated (from Step 4) |

### 6.3 Configure Post Settings

1. **Auto-Post:** Enable to automatically post when publishing
2. **Post Template:** Customize your post format:
   ```
   {title}
   
   {excerpt}
   
   {url}
   
   #yourbusiness #yourhashtags
   ```
3. **Post Types:** Select which content types to auto-post
4. **Include Featured Image:** Enable to share images

### 6.4 Save Settings

Click **"Save Settings"** to store your configuration.

---

## Step 7: Test Your Setup

### 7.1 Test Connection

1. In plugin settings, click **"Test Connection"**
2. ✅ Green success message = API connection works
3. ❌ Error message = Check troubleshooting guide

### 7.2 Test Post

1. Create a new post or page in WordPress
2. Publish it
3. Check your Facebook Page for the new post

### 7.3 Check Post Log

1. Go to **Social Auto Post** → **Post Log**
2. Verify the post status shows "Success"
3. If "Failed", click to see the error message

---

## Quick Reference

### Your Credentials

Keep these safe:

| Credential | Value | Where to Find |
|------------|-------|---------------|
| App ID | `_______________` | App Dashboard |
| App Secret | `_______________` | App Dashboard → Settings → Basic |
| Page ID | `_______________` | Graph API `me/accounts` response |
| Page Token | `_______________` | Graph API `me/accounts` response |

### Important URLs

- [Facebook Developers](https://developers.facebook.com/apps/)
- [Business Manager](https://business.facebook.com/settings)
- [Graph API Explorer](https://developers.facebook.com/tools/explorer/)

---

## Next Steps

- Read the [Troubleshooting Guide](TROUBLESHOOTING.md) if you encounter issues
- Check [FAQ](FAQ.md) for common questions
- Configure advanced settings like scheduling and URL shortening

---

*Last updated: January 2026*
