Create an RSS feed of a selected Instagram user's recently published media using the v1 API.
Tags: Instagram, API, RSS
Questions/Comments: sahearn at gmail dot com
While Instagram is great for consuming media on a mobile device, there aren't any options for following a user (and their published media) via an RSS feed. Rather than opening up ten different apps just to see what my friends are up to, I prefer to follow whatever I can via a feed reader (such as Feedly). After creating a similar script for Twitter using their API, I decided to do the same for Instagram. Unfortunately, Instagram API is fairly restrictive. All requests must be authenticated, and (as of Dec 2015) all apps that wish to query other users' content must be reviewed and approved.
To use this script, you'll first need your own access token; so register your script and go through those steps for proper authentication.
I modeled my script after some research I found on the IBM DeveloperWorks library, which guided me through the JSON parsing I'd need to perform on the Instagram API response. Past that, I simply needed to extract the user's most recent media (using the appropriate API endpoint) and dropping them into a well-formed RSS/XML file. As I stated in my TweetPull script, this is primarily due to the API's rate limiting - I don't want to get flagged for spamming, so this forces me to schedule the script via cron, instead of risking it banging against Instagram in realtime.
Once the output file is created, I host it so an RSS reader can get to it. If you can't host the result, this will be useless to you.
Also as with TweetPull, I chose to pass the user id to the script as an argument. This means if I want to pull from 5 Instagram users, I have 5 entries in my crontab. (See Installation steps below.)
In general, a lot of improvements can be made here, but it's good enough for a v0.1 release. And I only did it because I'm devoted to RSS and I couldn't find anyone else doing something similar yet.
Latest: v0.1 (Jul 2016) - picfeed.zip
View source: picfeed.php
License: This script is released under the Apache v2.0 License.
When the script is executed, the specified Instagram user's profile will be read in the "basic" and "public_content" contexts. This means that any public-facing content in the user's profile and published media will be processed. The raw response data from the Instagram API is read, and the URL links/references to the most recently published media within that payload are written to a valid XML document. The script owner may store this file on a web host with the intention to be read later by an RSS reader. The file will only contain references to the Instagram user's id, and URL links to content hosted on Instagram. Media files are not read or stored in any way. The data object read from Instagram is destroyed upon script completion.
Updated: 07 Jul 2016