bnomei/kirby3-instagram

Kirby 3 Plugin to call Instagram API Endpoints

Installs: 121

Dependents: 0

Suggesters: 0

Stars: 10

Watchers: 0

Forks: 0

Open Issues: 1

Type:kirby-plugin

1.1.0 2019-08-16 13:45 UTC

README

GitHub release License Kirby Version Kirby 3 Pluginkit Build Status Coverage Status Gitter

Kirby 3 Plugin to call Instagram API Endpoints

Commercial Usage

This plugin is free but if you use it in a commercial project please consider to

Installation

  • unzip master.zip as folder site/plugins/kirby3-instagram or
  • git submodule add https://github.com/bnomei/kirby3-instagram.git site/plugins/kirby3-instagram or
  • composer require bnomei/kirby3-instagram

Usage

Config

You can set the token in the config.

return [
    // other config settings ...
    'bnomei.instagram.token' => 'YOUR-TOKEN-HERE',
];

Template

<?php
    $token = null; // default. this will cause loading from the config file or set it here...
    $token = 'YOUR-TOKEN-HERE';
    $endpoint = 'users/self/media/recent';
    $params = [
        'count' => 4
    ];
    $force = null; // default. this will cause refresh on global debug == true
    // $force = true; // always force refresh
    foreach(site()->instagram($token, $endpoint, $params, $force) as $data) {
        echo Kirby\Toolkit\Html::img(
            $data['images']['standard_resolution']['url']
        );
    }

Cache

This plugin does have a cache unless global debug options is set or your $force the refresh because the instagram api will stop working if you push to may requests in a period of short time.

TIP: all site()->instagram() function parameters are optional if their value is set in config.

Settings

debugforce

  • default: true will only write but never read cache in debug mode

expire

  • default: 60*24 in minutes. 0 will never expire (aka forever).

token

  • default: null you could add a default token

api

  • default: https://api.instagram.com/v1

endpoint

  • default: users/self/media/recent you could change default endpoint

params

  • default: [] you could change default params for api

Disclaimer

This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please create a new issue.

License

MIT

It is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.