Fetches and stores Instagram media from the Instagram Graph API for October CMS with OAuth authorization and automatic token management.
- 🔐 OAuth Authorization - Easy one-click Instagram connection
- 🔄 Auto Token Refresh - Automatically refreshes tokens before expiry
- 📸 Automatic Media Sync - Fetch Instagram media via Graph API
- 💾 Database Storage - Store media with metadata (likes, comments, captions)
- 👁️ Visibility Control - Show/hide individual media items
- 🎨 Frontend Component - Display media in customizable grid layouts
- ⚙️ Configurable Settings - API credentials, sync frequency, auto-hide old posts
- 🔧 Artisan Commands - Manual sync and token refresh via CLI
- 📅 Scheduled Tasks - Automated token refresh and media sync
- 🎯 Filter Options - Filter by media type, sort by date/engagement
- Place the plugin in
plugins/sixgweb/instagrammedia/ - Run migrations:
php artisan plugin:refresh Sixgweb.InstagramMedia
Quick Setup with OAuth (Recommended)
- Go to Meta for Developers
- Create a new Business app
- Add Instagram Basic Display product
- In Basic Display settings, add OAuth Redirect URI:
https://yoursite.com/backend/sixgweb/instagrammedia/oauth/callback - Copy your App ID and App Secret
- In October CMS:
- Go to Settings → Instagram Media
- Paste App ID and App Secret
- Click Save
- Click Connect Instagram Account
- Authorize on Instagram
- Done! Token is automatically managed
- Go to Meta for Developers
- Create a new Business app
- Add Instagram Basic Display product
- Note your App ID and App Secret
- Add an Instagram Test User in your app
- Generate a User Token
- Exchange for long-lived token (60 days):
https://graph.instagram.com/access_token? grant_type=ig_exchange_token& client_secret={app-secret}& access_token={short-lived-token}
- Go to Settings → Instagram Media
- Enter your App ID, App Secret, and Access Token
- Set token expiration date (60 days from generation)
- Save settings
Via Backend:
- Navigate to Instagram Media in the backend menu
- Click "Sync from Instagram" button
Via Artisan Command:
php artisan instagrammedia:sync
php artisan instagrammedia:sync --limit=50Add the component to any page:
[instagramMediaList]
limit = "12"
mediaType = "all"
sortOrder = "timestamp desc"
displayType = "grid"
==
{% component 'instagramMediaList' %}- limit - Number of items to display (default: 12)
- mediaType - Filter:
all,IMAGE,VIDEO,CAROUSEL_ALBUM - sortOrder - Sort by:
timestamp desc,timestamp asc,like_count desc,comments_count desc - displayType - Layout:
grid,masonry,carousel,list
- View all synced Instagram media
- Toggle visibility for individual items
- Bulk toggle visibility for multiple items
- View engagement metrics (likes, comments)
- API Configuration - App credentials and access token
- Sync Settings - Auto-sync, frequency, media limit
- Auto-hide - Automatically hide posts older than X days
GET /me/media- Fetch user's mediaGET /{media-id}- Get specific media itemGET /refresh_access_token- Refresh long-lived token
id,media_type,media_url,thumbnail_urlpermalink,caption,timestampusername,like_count,comments_count
sixgweb.instagrammedia.access_media- Manage media in backendsixgweb.instagrammedia.access_settings- Configure plugin settings
Table: sixgweb_instagrammedia_media
instagram_id- Unique Instagram media IDmedia_type- IMAGE, VIDEO, or CAROUSEL_ALBUMmedia_url- Full resolution media URLthumbnail_url- Thumbnail URL (for videos)permalink- Instagram post URLcaption- Post caption texttimestamp- When posted on Instagramusername- Instagram usernamelike_count- Number of likescomments_count- Number of commentsis_visible- Display on frontend (boolean)
The plugin includes automatic token refresh:
- Daily Checks: Runs daily via scheduled task
- Smart Refresh: Only refreshes when within 7 days of expiry
- Extends Validity: Each refresh extends token for 60 more days
Make sure your cron is configured:
* * * * * cd /path-to-project && php artisan schedule:run >> /dev/null 2>&1Refresh Token (Backend):
- Go to Settings → Instagram Media
- Click "Refresh Token" button
Refresh Token (CLI):
php artisan instagrammedia:refresh-token
php artisan instagrammedia:refresh-token --forceDisconnect Account:
- Go to Settings → Instagram Media
- Click "Disconnect" button
The plugin registers these OAuth endpoints:
- Authorization:
/backend/sixgweb/instagrammedia/oauth/authorize - Callback:
/backend/sixgweb/instagrammedia/oauth/callback - Refresh:
/backend/sixgweb/instagrammedia/oauth/refresh - Disconnect:
/backend/sixgweb/instagrammedia/oauth/disconnect
- Generate a new long-lived token
- Update token expiration date in settings
- Verify your Instagram account has public posts
- Check that your access token has correct permissions
- Ensure the Instagram Test User is authorized
- Check your API credentials
- Verify token hasn't expired
- Check Instagram API rate limits
- October CMS v4.x
- PHP ^8.2
- GuzzleHTTP (included with October)
- Valid Instagram Basic Display app
- Instagram Business or Creator account
Proprietary - Sixgweb
For issues or feature requests, contact the development team.