Download the PHP package marcorieser/statamic-instagram without Composer
On this page you can find all versions of the php package marcorieser/statamic-instagram. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download marcorieser/statamic-instagram
More information about marcorieser/statamic-instagram
Files in marcorieser/statamic-instagram
Package statamic-instagram
Short Description Statamic Instagram Business API lets you fetch data via the Instagram Business API into your Statamic site.
License proprietary
Informations about the package statamic-instagram
Statamic Instagram Business API
Statamic Instagram Business API lets you fetch data via the Instagram Business API into your Statamic site.
Features
- Fetch Instagram posts via Meta's Instagram Business API
- Fetch Instagram profile data via Meta's Instagram Business API
- Auto refreshing of Access Tokens
How to Install
You can install this addon via Composer:
How to Use
Installation
- Install the addon
- Publish the addon config by running
php artisan vendor:publish --tag=statamic-instagram-config
- Add your Access Token to the
account
section in the published config file. If you do not have a token, follow the instructions below.
Creating a Meta App / an Access Token
Create an Access Token for the API with these steps:
- Login with your Instagram credentials at https://developers.facebook.com
- Create a new app (choose
Other
as use case andBusiness
as the app type) - Add
Instagram
as a product to your app - Link your instagram account at
1. Generate access tokens
in theAPI setup with Instagram login
section of your app - Generate a token and add it to the config in Statamic
Further information on that topic in Meta's docs.
Display the feed
There is a {{ instagram:feed }}
tag, that fetches the media from the API and returns them as an array.
- The
limit
parameter defaults to12
. - The
handle
parameter defaults to the first account in the config.
Display a specific media
There is a {{ instagram:media }}
tag, that fetches just one specific media.
- The
id
parameter is required. - The
handle
parameter defaults to the first account in the config.
Display profile data
There is a {{ instagram:profile }}
tag, that fetches the profile information from the API and returns them as an array.
- The
handle
parameter defaults to the first account in the config.
Manipulate an image
You can manipulate external Instagram image URLs with Glide as usual:
_Since Statamic v5.43.0
, Glide supports external URLs with query params. Therefore, v2
of this addon removes the ability to proxy images and drops the ig_proxy
modifier._
Refreshing Tokens
A long-lived access token is valid for two months.
This would mean that it has to be refreshed manually before it expires.
When using the {{ instagram:feed }}
{{ instagram:media }}
tags,
this is handled automatically for you.
If you use the API exclusively in PHP, please make sure that you update the token yourself via the scheduler:
Please note that the frequency has to be between one day and the mentioned two months until the token expires.
Child Media (Album)
By default, the addon does not fetch child media for e.g. Albums since that requires additional requests to the API.
Therefore children
is null
.
In case you need child media, you can enable include_child_posts
in the addon config.
Using the API in PHP
There is a dedicated InstagramAPI
class to interact with the API. Its public methods are:
cacheKey(...$parts): string
profile(): Profile
feed(): Collection
getAccount(): Account
getLimit(): int
setLimit(int $limit): static
getUserId(): string
getHandle(): string
setHandle(string $handle): static
media(int $id): ?Media
refreshAccessToken(): bool
For example, this is how you fetch the feed. This will return you a Collection of Media
objects.
License
Statamic Instagram Business API is paid software with an open-source codebase. If you want to use it, you’ll need to buy a license from the Statamic Marketplace. The license is valid for only one project. Statamic itself is commercial software and has its own license.