Skip to content

Instagram API v1 compliant plugin that provides functions to get an array of Instagram posts for use in themes.

License

Notifications You must be signed in to change notification settings

rain2o/oauth-instagram-for-developers

Repository files navigation

oAuth Instagram For Developers

Instagram API v1 compliant plugin that provides functions to get an array of Instagram posts for use in themes.

Instagram API v1 compliant plugin that provides functions to get an array of Instagram posts for use in themes.

There are multiple functions available depending on your Instagram feed needs. For more details about the Instagram API, check out Instagram's Developer Documentation. The available functions in this plugin are as follows.

  • getInstaByShortcode($shortcode): Gets a single Instagram post using the given shortcode. The shortcode is the alpha-numeric id in the url of the post, after https://instagram.com/p/.
  • getInstaByUrl($insta_url): Gets a single Instagram post using the full URL of the post. This works the same as the shortcode, but it does not require the user to strip the shortcode from the URL. The parameter $insta_url should look something like https://instagram.com/p/A1B2C3.
  • getInstaByTag($tag, $count): Returns an array of the most recent public posts using the given hashtag, limited to $count. The parameter $tag should not include the hashtag.
  • getInstaFeed($count): Returns an array of the most recent posts by the user provided in the plugin's Settings page, limited to $count.

Installation

Upload the files to your wp-content/plugins directory.

Navigate to the Settings > Instagram oAuth.

Here you'll find settings fields to authenticate with Instagram. You'll need to create a new Application on https://instagram.com/developer. Under Valid redirect URIs, include http://{base-url}/wp-admin/options-general.php?page=ifd_settings as a valid URI, replacing {base-url} with the base URL of your WordPress site. In the Security tab, be sure to uncheck "Disable Implicit OAuth" for this to work.

Once you've create the app, copy and paste your Client ID and Client Secret into their respective fields in the plugin settings page and click Save Changes. After you have saved, click the link provided in the settings page's description to generate an authentication token. It will redirect you back to the settings page with the Authentication ID already filled out. You will need to click Save Changes again to save this value. If it does not fill out the field with that value there was an issue validating your application. Make sure your settings are correct.

Now, anywhere in your theme files you can call the functions provided to get Instagram posts.

Output

For functions that return only a single post, such as getInstaByShortcode the returned data will be a dictionary array inside data. For example:

<?php
	$instagrams = getInstaByShortcode('my-shortcode');
	var_dump($instagrams->data);
?>

The other methods that return more than one post will be similar, but you will have to loop through the data. For example:

<?php
	$instagrams = getInstaFeed(5);
	foreach($instagrams->data as $insta){
		var_dump($insta);
	}
?>

You can look through the dump or read up on Instagram's API documentation to find out more about the returned data and how to retrieve it.

About

Version: 1.0

Written by Joel Rainwater of Pyxl - http://www.thinkpyxl.com

TODO

Add caching capabilities to reduce API calls

About

Instagram API v1 compliant plugin that provides functions to get an array of Instagram posts for use in themes.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages