Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
44 lines (40 sloc) 1.525 kb
<?php
/**
* Instagram PHP API example usage.
* This is the entry point of your application, it will detect whether
* the user is already authenticated and will present her the login
* window in case she is not.
*
* If the authentication token is already stored (as a cookie in this case),
* the user will be redirected to callback.php which is basically the same
* URI callback that you must set up with Instagram as the return address
* for your application on their developers section:
* http://instagr.am/developer/
*
*
* If you have any question, check http://mauriciocuenca.com/ for the
* latest updates
*/
require_once 'Instagram.php';
/**
* Configuration params, make sure to write exactly the ones
* instagram provide you at http://instagr.am/developer/
*/
$config = array(
'client_id' => 'e8d6b06f7550461e897b45b02d84c23e',
'client_secret' => '2357fc69da344800acef2592ef647491',
'grant_type' => 'authorization_code',
'redirect_uri' => 'http://mauriciocuenca.com/qnktwit/confirm.php',
);
/**
* This is how a wrong response looks like
* array(1) { ["InstagramOAuthToken"]=> string(89) "{"code": 400, "error_type": "OAuthException", "error_message": "No matching code found."}" }
*/
session_start();
if (isset($_SESSION['InstagramAccessToken']) && !empty($_SESSION['InstagramAccessToken'])) {
header('Location: callback.php');
die();
}
// Instantiate the API handler object
$instagram = new Instagram($config);
$instagram->openAuthorizationUrl();
Jump to Line
Something went wrong with that request. Please try again.