A openFrameworks addon for Instagram API.
ofxInstagram is an addon for openFrameworks (v0.8.0+) that allows users to utilise the Instagram API in C++. The addon lets you pull data from instagram such as image links, like and comments. Aswell as posting comments, liking and finding photographs.
If you would like to contribute to the addon feel free to fork, hack and modify the code. Also drop me a line and let me know how you end up using the addon.
- openFrameworks v0.8.0+
- libcurl (Raspberry Pi)
sudo apt-get install libcurl4-openssl-dev
What the addon includes
- ofxInstagram src
- libcurl library
- Simple example which just returns json string
- Example which pulls the image urls from the json
- Example which allows you to save images from Instagram to your Data folder (this does include a ImageExtension Class)
Here are a couple of helper guides to get started with ofxInstagram.
To start using the API, you need to get an access_token, which grants you access to the API elements. If you go to http://instagram.com/developer/authentication/ you can see how Instagram authorises your app. We'll be simplifying this process slightly.
First grab yourself an Instagram account.
Then sign in to http://instagram.com/developer/
Go to Manage Clients and Register a New Client
Choose an Name for your Client and fill in the description.
In the oAuth uri and Website URL, type
Uncheck the Implicit OAuth check box, then Save.
This should generate some keys for you.
Now in your web browser, goto
https://instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=http://127.0.0.1&response_type=token&scope=basic+likes+relationshipschanging out the CLIENT ID for your own. This sets the permissions of your API Calls, so you can like and change user relationships. (If you want the ability to post comments you need to get permissions from instagram first. Follow this guide https://help.instagram.com/contact/185819881608116)
This will bring up a window asking you give access to the Application, click Authorize.
Then the Window should go white, look at the url bar you should now have something like
Copy that access_token and put it somewhere safe.
The addon should have some examples already for you to try, but if you want to build a new project use the project generator.
There is a .crt file stored in the addon folder. You will need to copy this in to the data folder of your application. This allows you to securely connect to the Instagram API.
In the xcode.proj file go to Build Phases then to Run Scripts, add the following code. This copies the data from the data folder to the data folder of the .app file.
cp -r bin/data "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Resources";
Copy the .crt and paste it into your apps data folder.
You'll need to add the libcurl.a file to the Link Binary with Libraries section. Found in Build Phases.