function nextend_api_auth_flow() { $api_key = NextendRequest::getVar('api_key'); $api_secret = NextendRequest::getVar('api_secret'); $redirect_uri = NextendRequest::getVar('redirect_uri'); if (session_id() == "") { @session_start(); } if (!$api_key || !$api_secret || !$redirect_uri) { $api_key = isset($_SESSION['api_key']) ? $_SESSION['api_key'] : null; $api_secret = isset($_SESSION['api_secret']) ? $_SESSION['api_secret'] : null; $redirect_uri = isset($_SESSION['redirect_uri']) ? $_SESSION['redirect_uri'] : null; } else { $_SESSION['api_key'] = $api_key; $_SESSION['api_secret'] = $api_secret; $_SESSION['redirect_uri'] = $redirect_uri; } if ($api_key && $api_secret) { require_once dirname(__FILE__) . "/api/Instagram.php"; $config = array('client_id' => $api_key, 'client_secret' => $api_secret, 'redirect_uri' => $redirect_uri, 'grant_type' => 'authorization_code'); $instagram = new Instagram($config); $accessCode = $instagram->getAccessCode(); if ($accessCode === null) { $instagram->openAuthorizationUrl(); } else { $accessToken = $instagram->getAccessToken(); unset($_SESSION['api_key']); unset($_SESSION['api_secret']); unset($_SESSION['redirect_uri']); echo '<script type="text/javascript">'; echo 'window.opener.setToken("' . $accessToken . '");'; echo '</script>'; } } }
* 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' => 'e1d602f8517645749de38593dbf9ad25', 'client_secret' => '63dbfae2a6444956802e269384fc05cc', 'grant_type' => 'authorization_code', 'redirect_uri' => 'http://www.HoopsMap.com/instagram/'); /** * 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: index.php'); die(); } **/ // Instantiate the API handler object $instagram = new Instagram($config); $instagram->openAuthorizationUrl(); ?>
public function login() { $instagram = new Instagram($this->config); $instagram->openAuthorizationUrl(); }