digitoimistodude/dude-insta-feed

This package is abandoned and no longer maintained. No replacement package was suggested.

Dude Instagram feed

0.1.0 2017-07-27 18:03 UTC

This package is auto-updated.

Last update: 2021-09-26 12:33:32 UTC


README

WordPress plugin to get latest images from Instagram user feeds.

Basically this plugin fetches images from Instagram, saves those to transient and next requests will be served from there. After transient has expired and deleted, new fetch from Instagram will be made and saved to transient. This implements very simple cache.

Handcrafted with love at Digitoimisto Dude Oy, a Finnish boutique digital agency in the center of Jyväskylä.

NOTE!

DEPRECATED! This plugin does not work so well after Instagram has tightened their API usage. Better plugin to use is ig-graph-feed by Jake Peterson or our image-user-feed which bypass the official API.

Table of contents

  1. Please note before using
  2. License
  3. Legal
  4. Usage
  5. Usage example for displaying user feed
  6. Limiting feed items
  7. Hooks
  8. Composer
  9. Contributing

Please note before using

This plugin is not meant to be "plugin for everyone", it needs at least some basic knowledge about php and css to add it to your site and making it look beautiful.

This is a plugin in development for now, so it may update very often.

License

Dude insta feed is released under the GNU GPL 2 or later.

Legal

Please read Instagram's TOC to determine can you use images and what restrictions there may be.

Usage

This plugin does not have settings page or provide anything visible on front-end. So it's basically dumb plugin if you don't use any filters listed below.

Only mandatory filter to use is dude-insta-feed/access_token/user=$userid.

Get images by calling function dude_insta_feed()->get_user_images(), pass user id as a only argument. User's id can be obtained with this tool.

Usage example for displaying user feed

  1. Go to instagram.com/developer and register an application for your WordPress site. Please note that application must be registered with that exact user account you want to pull images from!
  2. Disable Implicit oAuth2 from security for next step to work.
  3. Generate access token by going to this url and adding your CLIENT ID and REDIRECT URIs to their appropriate places and click Authorize.
  4. Enable Implicit oAuth2 back.
  5. Get the code after #access_token= in the following URL and add this snippet to functions.php. Your user ID is in the beginning of access token, just before tge dot.
/**
 * Dude Instagram hashtag feed.
 */
add_filter( 'dude-insta-feed/access_token/user=USERID_HERE', function() { return 'ACCESS_TOKEN_HERE'; } );
  1. Add this loop to wherever you want to display your images:
<?php
$instagram_feed = dude_insta_feed()->get_user_images( 'USERID_HERE' );
foreach ($instagram_feed['data'] as $item) : ?>
    <img src="<?php echo $item['images']['standard_resolution']['url']; ?>" alt="" />
<?php endforeach; ?>

Limiting feed items

/**
 * Limit Instagram feed items
 */
add_filter( 'dude-insta-feed/user_images_parameters', function( $parameters ) {
  $parameters['count'] = '6';
  return $parameters;
} );

Hooks

All the settings are set with filters, and there is also few filters to change basic functionality and manipulate data before caching.

dude-insta-feed/access_token/user=$userid

Because Instagram's API restrictions, every user needs their own access token. Access token can be generated following this instruction.

Set the access token for specific user. Passed arguments are default access_token and user id.

Defaults to empty string.

dude-insta-feed/user_images_transient

Change name of the transient for user images, must be unique for every user. Passed arguments are default name and user id.

Defaults to dude-insta-user-$userid.

dude-insta-feed/user_images_parameters

Modify api call parameters, example count of images. Only passed argument is array of default parameters.

Defaults to access_token defined for user and image count of five.

dude-insta-feed/user_images

Manipulate or use data before it's cached to transient. Only passed argument is array of images.

dude-insta-feed/user_images_lifetime

Change image cache lifetime. Only passed argument is default lifetime in seconds.

Defaults to 600 (= ten minutes).

Composer

To use with composer, run composer require digitoimistodude/dude-insta-feed dev-master in your project directory or add "digitoimistodude/dude-insta-feed":"dev-master" to your composer.json require.

Contributing

If you have ideas about the plugin or spot an issue, please let us know. Before contributing ideas or reporting an issue about "missing" features or things regarding to the nature of that matter, please read Please note section. Thank you very much.