当前位置: 首页>>代码示例>>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;未经允许,请勿转载。