-
Notifications
You must be signed in to change notification settings - Fork 0
Kirby Instagram Feed
Instagram feed on your website for Kirby 3.
This plugin powered by the new Instagram Basic Display API.
There is an Instagram API request limit (Instagram API rate limits). Don't worry! The plugin caches it periodically for the time you set from config.
Instagram access token expires after 2 months (60 days) by default. The plugin automatically refresh the token. If cache is enabled the plugin will do it 1 week before, otherwise it will do it on every request and this is not recommended. So you don't need to do anything.
- Download the latest release
- Unzip downloaded file
- Copy/paste unzipped folder in your
/site/plugins
folder
You can use sample basic snippet of plugin:
<?php snippet('instagram-feed') ?>
If you want to customize it, you can look the example usage below:
<?php foreach (site()->instagramFeed() as $feed): ?>
<a href="<?= $feed->permalink() ?>" target="_blank">
<img title="<?= $feed->caption() ?>" src="<?= $feed->media_url() ?>">
</a>
<?php endforeach ?>
- $feed->id()
- $feed->caption()
- $feed->media_type()
- $feed->media_url()
- $feed->permalink()
- $feed->thumbnail_url()
- $feed->timestamp()
- $feed->username()
Also site()->instagramFeed()
and all items ($feed
) in it are collection objects and have all collection methods.
The default values of the package are:
Option | Type | Default | Description |
---|---|---|---|
accessToken | string | null | Access token for Instagram Basic Display API. |
cache | boolean | true | Enable/disable caching feed and refresh token request. Highly recommended that the cache be enabled to avoid exceeding api request limit. |
debug | boolean | false | Enable/disable debugging for this plugin. |
expire | int | 1440 | Sets how long the feed items are cached as minutes. Default is one day. |
limit | int | 20 | Sets how many feed items are fetch from API. |
All the values can be updated in the config.php
file and prefixed with owebstudio.instagram-feed.
.
<?php
// /site/config/config.php
return [
'owebstudio.instagram-feed' => [
'accessToken' => 'INSTAGRAM_ACCESS_TOKEN',
'cache' => true,
'debug' => false,
'expire' => 180, // 3 hours
'limit' => 10 // fetch limit
]
];
Here are a few resources on Instagram access token creation: