instaplatform
instaplatform copied to clipboard
A platform for building real-time Instagram web applications
Note: Socket.io, as of v.0.7, supports native Channels. I suspect it'd be far more efficient to utilise these at some point in the future.
Introduction
This is intended as a platform to allow for the rapid development Instagram-fed real-time web applications.
See my blog post for some background on the project.
What does what
I find it rather easy to get lost when dealing with JavaScript on both the front- and back-ends. Throw the multi-threaded, asynchronous nature of Node.js and Socket.io, and things can get a little messy, so, here's a very basic overview of the architecture:
(Will expand on this later...)
- subscriptions.js - Socket server
- server.js - File server
- helpers/* - Subscription channel handlers
How can you help?
- Front-end library
- Geography and Location real-time handlers
- Extend to include more static API methods (comments, likes, etc.)
Installation
You'll need to sign up for an Instagram API developer account and create a client before you do anything, go here:
http://instagr.am/developer/manage/
Install Node.js
curl -O http://nodejs.org/dist/node-v0.4.8.tar.gz
tar xvf node-v0.4.8.tar.gz
cd node-v0.4.8
./configure
sudo make
sudo make install
Install and run Redis
curl -O http://redis.googlecode.com/files/redis-2.2.1.tar.gz
tar xvf redis-2.2.1.tar.gz
cd redis-2.2.1
./configure
sudo make
sudo make install
cd /your-app/
./redis-server conf/redis.conf
Install NPM (Node package manager)
curl http://npmjs.org/install.sh | sh
Install required node libraries
cd /your-app/
sudo npm install redis
sudo npm install socket.io
sudo npm install express
sudo npm install ejs
sudo npm install instagram-node-lib
sudo npm install geo
Add your client_id and client_secret to settings.js
./node server.js
Subscribe to your authenticated users' feeds
All other subscriptions are handled by the app code itself, but as this is a one-off, you may as well subscribe to it now.
curl -F 'client_id=CLIENT-ID' \
-F 'client_secret=CLIENT-SECRET' \
-F 'object=user' \
-F 'aspect=media' \
-F 'verify_token=userSubscription' \
-F 'callback_url=http://YOUR-CALLBACK/URL' \
https://api.instagram.com/v1/subscriptions/
Navigate to http://your-server:3000/