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


PHP GraphUser::classname方法代碼示例

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


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

示例1: loginWithToken

 /**
  * login with token
  *
  * @param String $accessToken, $appId, $appSecret
  *
  * @return boolean
  */
 public function loginWithToken($accessToken, $appId, $appSecret)
 {
     FacebookSession::setDefaultApplication($appId, $appSecret);
     $session = new FacebookSession($accessToken);
     $FacebookRequest = new FacebookRequest($session, 'GET', '/me');
     $response = $FacebookRequest->execute();
     $this->graph = $response->getGraphObject(GraphUser::classname());
     if ($session) {
         return true;
     }
     return false;
 }
開發者ID:Juli55,項目名稱:mvc-framework,代碼行數:19,代碼來源:FacebookLogin.php

示例2: FacebookRedirectLoginHelper

FacebookSession::setDefaultApplication($app_id, $app_secret);
$helper = new FacebookRedirectLoginHelper($redirect_url);
$sess = $helper->getSessionFromRedirect();
//check if facebook session exists
if (isset($_SESSION['fb_token'])) {
    $sess = new FacebookSession($_SESSION['fb_token']);
}
//logout
$logout = 'http://packetcode.com/apps/newfblogin&logout=true';
//4. if fb sess exists echo name
if (isset($sess)) {
    //store the token in the php session
    $_SESSION['fb_token'] = $sess->getToken();
    //create request object,execute and capture response
    $request = new FacebookRequest($sess, 'GET', '/me');
    // from response get graph object
    $response = $request->execute();
    $graph = $response->getGraphObject(GraphUser::classname());
    // use graph object methods to get user details
    $name = $graph->getName();
    $id = $graph->getId();
    $image = 'https://graph.facebook.com/' . $id . '/picture?width=300';
    $email = $graph->getProperty('email');
    echo "hi {$name} <br>";
    echo "your email is {$email} <br><Br>";
    echo "<img src='{$image}' /><br><br>";
    echo "<a href='" . $logout . "'><button>Logout</button></a>";
} else {
    //else echo login
    echo '<a href="' . $helper->getLoginUrl(array('email')) . '" >Login with facebook</a>';
}
開發者ID:Canyian,項目名稱:fbloginlogout,代碼行數:31,代碼來源:index.php


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