xddesigners / silverstripe-instagram-feed
Instagram Feed for Silverstripe with Basic Display API
Package info
github.com/xddesigners/silverstripe-instagram-feed
Type:silverstripe-vendormodule
pkg:composer/xddesigners/silverstripe-instagram-feed
Requires
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Display an Instagram feed anywhere on your Silverstripe site. The module connects to the Instagram API with Instagram Login, caches an account's latest media in the database, and renders it through ready-made templates (grid, swiper/carousel) or your own markup.
Authentication is handled entirely from the CMS: enter your Meta app credentials, click Authenticate with Instagram, and the module stores a long-lived access token and refreshes it automatically. A scheduled task keeps the cached feed up to date, so the front end never has to call the Instagram API on page load.
Features
- Connect an account straight from Settings → Instagram — no manual token copying.
- Long-lived tokens stored in the database and refreshed automatically (every 30 days).
- Media cached in the database; the front end reads the cache, so pages stay fast and don't hit rate limits.
- Template globals and bundled includes (grid, swiper, carousel) for quick output, or build your own.
- Webhook verification endpoint for Meta app subscriptions.
Requirements
- Silverstripe CMS 6
- An Instagram professional account (Business or Creator)
- A Meta (Facebook) app with the Instagram API with Instagram Login product
Installation
composer require xddesigners/silverstripe-instagram-feed
Then build the database and flush:
/dev/build?flush=all
Setup (Meta app)
Setting up the Meta app is the fiddly part — the module takes over once it's done. This is a one-time configuration:
-
Open the Meta for Developers dashboard and create an app.
-
Add the Instagram product and set it up for Instagram API with Instagram Login. (The older Instagram Basic Display API was deprecated by Meta in December 2024 and no longer works.)
-
Under the Instagram login settings, add this OAuth redirect URI exactly:
https://your-domain.tld/__instaauth -
Note the Instagram App ID and Instagram App Secret.
-
Make sure the Instagram account is a professional (Business/Creator) account. While the app is in development mode, add that account as an Instagram tester and accept the invite from the Instagram app settings.
Connecting the account
- In the CMS, open Settings → Instagram.
- Paste the App ID and App Secret and save. A verification token is generated for you.
- Click Authenticate with Instagram and authorise the account. You're redirected back to
/__instaauthand a long-lived token is stored automatically. - Click Refresh Instagram Feed (or run the task below) to pull in the latest media.
The module requests the instagram_business_basic scope and refreshes the long-lived token by
itself once it's older than 30 days.
Keeping the feed updated
Media is cached in the database. Refresh it with the Refresh Instagram Feed button in Settings, or run the update task — on the command line:
sake tasks:XD-InstagramFeed-Tasks-InstagramUpdateTask
or in the browser:
/dev/tasks/XD-InstagramFeed-Tasks-InstagramUpdateTask
Schedule the command (cron, Plesk scheduled task, etc.) to keep the feed fresh — hourly is plenty.
Templates
Two global variables are available in any template.
$InstagramMedia($limit) returns the cached media. Each item exposes the standard Instagram
fields — $media_type (IMAGE / VIDEO / CAROUSEL_ALBUM), $media_url, $thumbnail_url,
$permalink, $caption and $caption_short:
<div class="row"> <% loop $InstagramMedia(12) %> <a href="$permalink" target="_blank" rel="noopener" class="col-3"> <% if $media_type == "VIDEO" %> <video src="$media_url" poster="$thumbnail_url" muted loop autoplay playsinline></video> <% else %> <img src="$media_url" alt="$caption" loading="lazy"> <% end_if %> </a> <% end_loop %> </div>
$InstagramProfile exposes the connected account's profile (e.g. $InstagramProfile.username).
Or drop in one of the bundled includes:
<% include XD\InstagramFeed\Includes\InstagramFeed %> <%-- default grid --%> <% include XD\InstagramFeed\Includes\InstagramFeed_grid %> <% include XD\InstagramFeed\Includes\InstagramFeed_swiper %> <%-- bring your own Swiper JS --%>
Copy any of them into your theme under templates/XD/InstagramFeed/Includes/ to customise the markup.
Credits
Thanks to @lerni and instagram-basic-display-feed-element, which this module builds upon and refactors. API access is provided by espresso-dev/instagram-php.
License
BSD-3-Clause — see LICENSE.