pixelpoems / silverstripe-instagram-feed
Silverstripe module that generates an instagram feed for a given user.
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:silverstripe-vendormodule
Requires
- php: >=7.4 || ^8.0
- ext-curl: *
- silverstripe/cms: ^4.0 || ^5.0
- silverstripe/framework: ^4.0 || ^5.0
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is auto-updated.
Last update: 2025-05-27 10:55:54 UTC
README
This module provides a service to get the latest posts from an instagram account. It also provides a DNA Elemental Element to display the feed. This is only a basic implementation and can be extended by your own needs. You need to provide an access token to use this module. To use this you need to create an instagram developer app and an instagram api app. See External Requirement Setup for more information. It is necessary to use a public instagram account to use this module (it's a limitation of the instagram api).
Requirements
- Silverstripe CMS ^4.0 || ^5.0
- Silverstripe Framework ^4.0 || ^5.0
External Requirements:
- Meta Developer App (Instruction)
- Instagram Basic Display API (Instruction)
- Public Instagram Account
Installation
composer require pixelpoems/silverstripe-instagram-feed
Configuration
You can add your instagram access token (Follow Instructions to get the token) within a yml config:
Pixelpoems\InstagramFeed\Services\InstagramService: instagram_access_token: ''
or you set a .env
Variable:
INSTAGRAM_ACCESS_TOKEN=''
If both variables are given, the yml variable will be used.
Furthermore, you can set a default size:
Pixelpoems\InstagramFeed\Services\InstagramService: default_post_size: 250
Usage
This module comes with a configured Instagram Feed Element (Usage with DNA Elemental).
If you want to use the feed somewhere else you can include the service like this:
public function getInstagramFeed(): ArrayList { $service = InstagramService::create('page_' . $this->ID); // Make sure to use a unique identifier for the service for caching purposes // To use the reduced display which only renders images (no carousels or videos) $service->setReducedDisplay(true); return $service->getFeed($limit = 12); }
After that you can include the feed include in your template file:
<% include Pixelpoems\InstagramFeed\Feed Feed=$InstagramFeed %>
Caching
The Instagram Feed is cached for 60 minutes by default to avoid reaching the rate limit of the Instagram API. Rate Limiting You can change the cache time by setting the cache time in the yml config:
Pixelpoems\InstagramFeed\Services\InstagramService: cache_time: 3600 # seconds
The Instagram Post
Key | Description |
---|---|
ID |
ID of the Instagram Post |
MediaType |
Type of Instagram MediaIMAGE CAROUSEL_ALBUM VIDEO |
Link |
Permalink for the Instagram Post |
ProfileLink |
Link of the Instagram Profile |
Username |
Username of the instagram profile |
MediaSrc |
Source of the Media (Image Source for IMAGE , First Image Source for CAROUSEL_ALBUM and Thumbnail Source for VIDEO ) |
VideoSrc |
Video Source - only available for Media Type VIDEO |
Caption |
Caption of the Instagram Post |
Timestamp |
Timestamp of the Instagram Post |
Children |
Contains the information of the child elements [ID , MediaSrc ]- only available for Media Type CAROUSEL_ALBUM |
DefaultSize |
Default Size of post 250 |
External Requirement Setup
Meta Developer App
To use the Instagram API you have to create a Meta App first.
- Go to https://developers.facebook.com/apps/create/ and select Type (Use "Business").
- Provide your App details (Name and contact mail).
- Select "Instagram" from the product list.
https://developers.facebook.com/docs/instagram-platform/instagram-api-with-instagram-login/
- Add User
- Select Instagram-Tester
- Search for your Instagram account and add it as tester.
- Go to your Instagram account settings page > App and Websites > Tester invites, accept the invite. https://www.instagram.com/accounts/manage_access/
- Back to "Products > Instagram > API-Einrichtung mit Instagram-Login" on the product overview (left menu).
- Click on 1. User Token Generator, your Instagram account should appear in the list, then click "Generate Token" button for authorize and generate long-lived access token for Instagram. And copy the token.
- Use this token within your yml config or your .env configuration or the yml setup (see Configuration).
Reporting Issues
Please create an issue for any bugs you've found, or features you're missing.
ToDos
- Add option to set default_post_size as square