Instagram: How To Use The API

API

Using the Instagram API

Presentation

Instagram, this social network based entirely on image sharing has been a success, launched in October 2010, which counts more than 100 million registered today, including some 7.5 million active users daily . The company was acquired by Facebook on April 9, 2012. Mainly used since Android and iOS smartphones , Instagram has recently proposed an API to develop sites and applications using their resources to open up new possibilities for users. We will see through this article, a mini-tutorial, how to exploit this API.

Pre-requisites

Before starting to develop, you need an Instagram account, if you do not already have one, I invite you to create one from your Smartphone by downloading the application, it is the only solution for the moment to create an Instagram account.

Once you have an account, go to the following address:

http://instagram.com/developer/

Log in to your account and register your application with the “Register Your Application” button

Instagram - API
Instagram – API

You will need to enter some parameters such as:

  • -The name of your application
  • -The description
  • -The address of your site
  • -The URI redirect address, the page to which the users will be returned after accepting or refusing to authenticate.

Once your application is registered, Instagram will give you a CLIENT_ID and a CLIENT_SECRET specific to your application, you will need it for the rest of the adventure.

authentication

Now it will be necessary to direct the users that you want to authenticate with Instagram on this url:

https://instagram.com/oauth/authorize/?client_id= CLIENT-ID & redirect_uri = REDIRECT-URI & response_type = token

Taking care to replace the CLIENT-ID and REDIRECT-URI with those you generated the Instagram application.

By default, you have access to the basic permissions to access all the member’s photos, profile information, subscriber list and subscriptions.

If you want to have more information about your user, it will then have to the end of the url add:

& Scope = PARAMETERS

By taking care to replace parameters with one of the following parameters:

  • basic – default setting
  • likes – liké or unliké photos of Instagram users
  • relationships – subscribe or unsubscribe to Instagram users
  • comments – write or remove comments

If you want to have two parameters, for example, just separate them by a plus like this:

& Scope = likes + comments

Once your url authentication associated with a link or button, here is the window you have by clicking on it:

Instagram - API Authorization
Instagram – API Authorization

If the user refuses to identify himself via your application, he will be redirected to your redirect page defined in the application with the following attributes:

? Error = access_denied & ERROR_REASON = user_denied & ERROR_DESCRIPTION = The user + + + your + request denied

So remember to predict the error where the user does not accept the error.

On the other hand if, on the contrary, it has accepted you will receive a code attribute with a token in parameters, like this  ? Code = ddfds564654ds6f54ds65fds65f465ds4f6

Once this code is received you will need to perform a CURL operation to have a valid token. At the moment Instagram does not assign any expiration date to the token you will receive, but it is best to guard against some future future updates.

Related posts