/** * displayEditInstagram * * @return void */ function displayEditInstagram() { $this->displayHeader(); $config = getInstagramConfigData(); $callbackUrl = getDomainAndDir(); $callbackUrl .= 'settings.php?view=instagram'; $accessToken = getUserInstagramAccessToken($this->fcmsUser->id); $instagram = new Instagram($config['instagram_client_id'], $config['instagram_client_secret'], $accessToken); if (!$accessToken) { $url = $instagram->authorizeUrl($callbackUrl, array('basic', 'comments', 'likes', 'relationships')); $status = T_('Not Connected'); $link = '<a href="' . $url . '">' . T_('Connect') . '</a>'; } else { try { $feed = $instagram->get('users/self'); } catch (InstagramApiError $e) { die($e->getMessage()); } $status = sprintf(T_('Currently connected as: %s'), $feed->data->username); $status .= '<br/><br/><img src="' . $feed->data->profile_picture . '"/>'; $link = '<a class="disconnect" href="?revoke=instagram">' . T_('Disconnect') . '</a>'; } echo ' <div class="social-media-connect"> <img class="icon" src="ui/img/instagram.png" alt="Instagram"/> <h2>Instagram</h2> <p>' . T_('Connecting with Instagram will allow you to:') . '</p> <ul> <li>' . T_('Share your Instagram photos with this site.') . '</li> </ul> <div class="status">' . $status . '</div> <div class="action">' . $link . '</div> </div>'; $this->displayFooter(); }
<?php session_start(); require_once 'src/config.php'; require_once 'src/Instagram.php'; $access_token = isset($_SESSION['access_token']) ? $_SESSION['access_token'] : null; $instagram = new Instagram(CLIENT_ID, CLIENT_SECRET, $access_token); if (!$access_token) { // If there is no access token in the session, let's have the user authenticate our application... /* / You pass the Redirect Uri you registered with your app and an array of "scope" (aka permissions) you / want to grab from the user. There is also a third parameter "response_type" which defaults to "code" */ $loginUrl = $instagram->authorizeUrl(REDIRECT_URI, array('basic', 'comments', 'likes', 'relationships')); } else { try { $feed = $instagram->get('users/self/feed'); } catch (InstagramApiError $e) { die($e->getMessage()); } } ?> <?php if (isset($loginUrl)) { ?> <a href="<?php echo $loginUrl; ?> ">Log in</a> <?php