本文整理汇总了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;
}
示例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>';
}