PHPackages                             newism/craft3-instagram - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. newism/craft3-instagram

ActiveCraft-plugin[API Development](/categories/api)

newism/craft3-instagram
=======================

Instagram plugin to connect users / site to the Instagram Basic API

338PHPCI failing

Since May 1Pushed 6y ago1 watchersCompare

[ Source](https://github.com/newism/craft3-instagram)[ Packagist](https://packagist.org/packages/newism/craft3-instagram)[ RSS](/packages/newism-craft3-instagram/feed)WikiDiscussions master Synced 3mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Instagram plugin for Craft CMS 3.x
==================================

[](#instagram-plugin-for-craft-cms-3x)

Instagram plugin to connect elements to the Instagram Basic API via access tokens and the basic display api.

Requirements
------------

[](#requirements)

This plugin requires Craft CMS 3.4.0 or later.

Installation
------------

[](#installation)

To install the plugin, follow these instructions.

1. Open your terminal and go to your Craft project: `cd /path/to/project`
2. Then tell Composer to load the plugin: `composer require newism/craft3-instagram`
3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Instagram.

Instagram Plugin Overview
-------------------------

[](#instagram-plugin-overview)

This plugin creates a new field type that generates an Instagram API access token which allows you to query for an Instagram users media.

This plugin is different from other Instagram plugins becuase it:

- Uses the ([https://developers.facebook.com/docs/instagram-basic-display-api)\[Instagram](https://developers.facebook.com/docs/instagram-basic-display-api)%5BInstagram) Basic Display API\] to fetch user media
- Is implemented as a field type, not a global setting.

### Why a fieldtype?

[](#why-a-fieldtype)

Fieldtypes can be assigned to any element including Entries, Globals, Users. This gives you multiple use cases eg:

- Entries: Allow business listings entries to connect their own Instagram account
- Globals: Create a global field and connect your site Instagram account
- Users: Allow users to connect their own instagram account

Configuring Instagram Plugin
----------------------------

[](#configuring-instagram-plugin)

To configure this plugin you'll need the 'OAuth Redirect URI ' and 'Deauthorize Callback URL' found in the plugin settings.

Next follow the first three steps of the [Getting Started documention](https://developers.facebook.com/docs/instagram-basic-display-api/getting-started):

1. Create a Facebook App
2. Configure Instagram Basic Display
3. Add an Instagram Test User

Once you've created the Facebook App you will be provided with a App Id and App Secret. Enter these values in the plugin settings. Note: It's a good idea to store these values as [environment configuration](https://docs.craftcms.com/v3/config/environments.html).

Using Instagram
---------------

[](#using-instagram)

### Creating an Access Token

[](#creating-an-access-token)

Once you've configured the plugin you'll need to create a new field and assign it to an Element. To test I recommend creating a new 'Instagram' field and assign it to a Global Set.

Edit the Global set and click "Connect Instagram" in the field you created. Make sure the user you're trying to connect is one of the testers setup in Step 3. of the getting started documentation.

If all goes well you should be asked to authorise your Facebook App, a long life access token will be created and displayed in your custom field.

Save the global set.

Fetching user media
-------------------

[](#fetching-user-media)

Once you have a token you can fetch the connected users media. In your template paste the following (change `entry.instagramToken` to the name of your global field.

```
{# Check if a token is set #}
{% if entry.instagramToken %}
    {# Fetch the user media #}
    {% set userMedia = craft.instagram.fetchUserMedia(entry.instagramToken) %}
    {# Check userMedia was returned #}
    {% if userMedia.data|default() | length %}
        {# Loop over the user media #}
        {% for entry in userMedia.data %}
            {# Output the image #}

        {% endfor %}
    {% endif %}
{% endif %}

```

The output of `craft.instagram.fetchUserMedia(entry.instagramToken)` matches the instagram API:

```
{
  "data": [
    {
      "id": "17895695668004550",
      "caption": ""
    },
    {
      "id": "17899305451014820",
      "caption": ""
    },
    {
      "id": "17896450804038745",
      "caption": ""
    },
    {
      "id": "17881042411086627",
      "caption": ""
    }
  ],
  "paging": {
    "cursors": {
      "after": "MTAxN...",
      "before": "NDMyN..."
      },
    "next": "https://graph.faceb..."
  }
}

```

### Options

[](#options)

`craft.instagram.fetchUserMedia(token, [options])` takes two parameters:

1. token (required): the access token saved in the field
2. options (optional): an array with two possible keys:
    - cache: the number of seconds to cache the request. The default value is `null` (no caching). Following Yii's standards `0` is infinity.
    - fields: a comma delimited list of fields. The default value is `caption,id,media_type,media_url,permalink,thumbnail_url,timestamp,username,children`.

The fields option can contain any of the following:

FieldDescriptioncaptionThe Media's caption text. Not returnable for Media in albums.idThe Media's ID.media\_typeThe Media's type. Can be `IMAGE`, `VIDEO`, or `CAROUSEL_ALBUM`.media\_urlThe Media's URL.permalinkThe Media's permanent URL.thumbnail\_urlThe Media's thumbnail image URL. Only available on VIDEO Media.timestampThe Media's publish date in ISO 8601 format.usernameThe Media owner's username.childrenThe children if `media_type` is `CAROUSEL_ALBUM`### Caching

[](#caching)

It's recommend that you wrap the `craft.instagram.fetchUserMedia()` method in a craft {% cache %} tag or use some other type of template caching like Blitz.

Instagram Roadmap
-----------------

[](#instagram-roadmap)

Some things to do, and ideas for potential features:

- Release it
- Implement deauthorize callbacks
- Check PHP 7.3 &amp; 7.2 compatibility

Brought to you by [Leevi Graham](https://newism.com.au)

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/54c91398084bc17848b56c2dc015c3c257fb5871f246f7296a99f1ceba072e4f?d=identicon)[leevigraham](/maintainers/leevigraham)

---

Top Contributors

[![leevigraham](https://avatars.githubusercontent.com/u/25124?v=4)](https://github.com/leevigraham "leevigraham (1 commits)")

### Embed Badge

![Health badge](/badges/newism-craft3-instagram/health.svg)

```
[![Health](https://phpackages.com/badges/newism-craft3-instagram/health.svg)](https://phpackages.com/packages/newism-craft3-instagram)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k16](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
