# Facebook Image Post Testing Guide

## 🐛 Issue Fixed: Missing Content and Hashtags

**Problem**: When uploading images to Facebook, the post content and hashtags were missing.

**Root Cause**: Facebook's API structure for posts with media is different - the caption needs to be attached to the photo during upload, not to the feed post.

## ✅ Solution Implemented

### What Changed:
1. **Caption Upload**: Content and hashtags are now added as `caption` parameter during photo upload
2. **Feed Post**: The feed post only contains the `attached_media` without duplicate message
3. **First Photo**: Caption is attached to the first photo only (Facebook best practice)

### Technical Details:
```php
// Before (incorrect)
$postData = [
    'message' => $content,
    'attached_media' => $uploadedMedia
];

// After (correct)
// Caption goes on photo upload:
$uploadParams = [
    'caption' => $content, // Content + hashtags here
    'published' => false
];

// Feed post only has media:
$postData = [
    'attached_media' => $uploadedMedia
    // No message field needed
];
```

## 🧪 How to Test

### Step 1: Create a Post with Image
1. Go to: `http://localhost:8000/websites/24/marketing/social`
2. Click "Create Post"
3. Add content: "Testing image upload with hashtags!"
4. Add hashtags: "#test #facebook #image"
5. Upload an image file
6. Select Facebook account
7. Click "Preview & Post"

### Step 2: Verify on Facebook
1. Check your Facebook page
2. The post should show:
   - ✅ **Image displayed**
   - ✅ **Caption**: "Testing image upload with hashtags! #test #facebook #image"
   - ✅ **Hashtags clickable**

### Step 3: Check Logs (if needed)
```bash
tail -f storage/logs/laravel.log
```

Look for log entries:
- "Facebook post data being sent"
- "Media uploaded to Facebook successfully"

## 🔍 Expected Behavior

### With Images:
- **Photo Upload**: Caption includes content + hashtags
- **Feed Post**: Only contains attached media reference
- **Result**: Image with caption appears on Facebook

### Without Images:
- **Feed Post**: Message includes content + hashtags
- **Result**: Text post appears on Facebook

## 🐛 Troubleshooting

### If content is still missing:
1. Check Laravel logs for "Facebook post data being sent"
2. Verify the `caption` parameter is included in photo upload
3. Ensure Facebook permissions include `pages_manage_posts`

### If images don't appear:
1. Check "Media uploaded to Facebook successfully" log
2. Verify file exists in `storage/app/public/social-media/`
3. Check Facebook API error responses

### Common Issues:
- **File too large**: Max 10MB for images
- **Invalid format**: Only JPG, PNG, GIF, WebP supported
- **Permissions**: Ensure `pages_manage_posts` permission
- **Token expired**: Refresh OAuth token

## ✅ Test Results Expected

After the fix, you should see:
- ✅ Image posted to Facebook
- ✅ Caption with your content
- ✅ Hashtags properly formatted
- ✅ Hashtags are clickable on Facebook
- ✅ No duplicate or missing text

The issue is now resolved and Facebook image posts will include the complete content and hashtags!