Recently, I have been very much into building Facebook applications. These applications vary from simple HTML forms for user data capture with fan gates to complex surveys—but with interactive, simple and engaging UI.
This also gave me an opportunity to experiment with various RESTful web services such as Facebook Open Graph, Twitter, Instagram, Spotify and Beatport APIs in unique manners. However, Instagram API was the one that I happened to use quite a lot while building few applications—therefore is the main focus of this post.
Going through development with Instagram API with no existing libraries based on its SDKs is a long story itself to tell at another time perhaps. Nonetheless, after facing much of trouble at the end I decided to build a custom PHP class. The idea is to make API’s various methods easily accessible. So here it is with a very initial version. It lacks few important methods currently which I shall be updating in few days. However, current methods are enough to authorise a user and get their basic information.
The package consists of two files.
ig-config.phpshall contain the configuration information that is required for
instagram.class.phpto work properly.
$ig = new JRIG( parameters );
$client_id $client_secret $redirect_uri $scope
The parameters are optional and by default an instance will take the parameter values from
However, if you like to create an instance on the go to use another registered Instagram client then you can do so by providing these optional parameters.
Following methods are currently available using a defined instance:
// returns an Instagram OAuth URI $ig->get_oauth_uri(); // returns client id $ig->get_client_id(); // returns client secret $ig->get_client_secret(); // returns scopes/permissions $ig->get_scope(); // returns user basic information including access_token as an associative Array() $ig->get_access_token();
A number of other methods are also part of this release. The project is available at GitHub under MIT License for use and contributions.