gacelabs / basic-instagram-feeds
Provides Instagram login code and feed collector for Silverstripe
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:silverstripe-vendormodule
Requires
- php: ^7.0|^8.2
- facebook/graph-sdk: ^5.7
- silverstripe/framework: ^4.0
This package is auto-updated.
Last update: 2024-03-30 00:33:45 UTC
README
A plugin for Silverstripe that request instagram feed information from the Instagram Basic Display API.
Requirements
- PHP ^7.0 | ^8.2
- Silverstripe 4.*
Installation
composer require gacelabs/basic-instagram-feeds
- For creating your Instagram App follow these steps
Usage
- Add this lines into your projects _config/app.yml or _config/mysite.yml:
Instagram: app_id: 'YOUR-INSTAGRAM-APP-ID' app_secret: 'YOUR-INSTAGRAM-APP-SECRET' generated_token: 'YOUR-INSTAGRAM-USER-TOKEN'
Get generated_token value:
Go to Instagram Basic Display at your Facebook developer site, then navigate to Basic Display > User Token Generator tab
add Instagram Test Users then click Generate Token
button to get the generated token for that instagram user
If you don't want to add the generated_token value:
After installation and applying usage and you don't have the generated_token value, run dev/build
then go to CMS Menu Settings > Instagram Tab
and click "Connect Account" button to initialized the first access token
- set own cache file and redirect uri:
Instagram: app_id: 'YOUR-INSTAGRAM-APP-ID' app_secret: 'YOUR-INSTAGRAM-APP-SECRET' cache_file: 'YOUR-CACHE-TXT-FILENAME' redirect_uri: 'YOUR-INSTAGRAM-REDIRECT-URI'
NOTE for redirect_uri:
Add it on your Instagram Client OAuth Settings Facebook developer site
then echo the GET parameter "code" into your redirect uri script to get your access token,
please refer to plugin controller
Pull the data
- In Back-end
$Posts = SiteConfig::current_site_config()->getInstagramPosts(); // or pull it from the cache file $Posts = SiteConfig::current_site_config()->getCachedFeed();
- In Front-end
<%-- Default --%> <% if $SiteConfig.getInstagramPosts.Count %> <% loop $SiteConfig.getInstagramPosts %> <%-- code here --%> <% end_loop %> <% end_if %> <%-- From cache file --%> <% if $SiteConfig.getCachedFeed.Count %> <% loop $SiteConfig.getCachedFeed %> <%-- code here --%> <% end_loop %> <% end_if %>
Returned fields
- ID
- Username
- Caption
- Link
- Image
- Timestamp
Re-extending the InstagramSiteConfigExtension Class
- Updating the result data
namespace Your\NameSpace; use SilverStripe\ORM\DataExtension; use SilverStripe\ORM\ArrayList; class YourAnotherInstagramSiteConfigExtension extends DataExtension { /** * Updates the default results. * * @param ArrayList $list (assembled result) * @param array $data (instagram posts results) */ public function updateInstagramPosts(ArrayList $list, $data) { // code } /** * Updates the cache results. * * @param $cache (parsed result) */ public function updateCachedFeed($cache) { // code } }
Bugtracker
Bugs are tracked on github.com (plugin issues).