當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Instagram::authorizeUrl方法代碼示例

本文整理匯總了PHP中Instagram::authorizeUrl方法的典型用法代碼示例。如果您正苦於以下問題:PHP Instagram::authorizeUrl方法的具體用法?PHP Instagram::authorizeUrl怎麽用?PHP Instagram::authorizeUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Instagram的用法示例。


在下文中一共展示了Instagram::authorizeUrl方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: displayEditInstagram

 /**
  * 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();
 }
開發者ID:lmcro,項目名稱:fcms,代碼行數:40,代碼來源:settings.php

示例2: isset

<?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 
開發者ID:yuva2achieve,項目名稱:instagram-php-oauth,代碼行數:31,代碼來源:index.php


注:本文中的Instagram::authorizeUrl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。