$facebook-> getuser()
include_once "facebook-php-sdk-master/src/facebook.php"; //initializing $config = array( 'appId' => 'myappid', 'secret' => 'myappsecret', 'cookie' => true ); $facebook = new Facebook($config); //getting user id $uid = $facebook->getUser(); if($uid) { echo $uid; $params = array( 'next' => $currentUrl ); $logoutUrl=$facebook->getLogoutUrl($params); // $params is optional echo "<a target="_blank" href="$logoutUrl">Logout from FB</a>"; //$facebook->destroySession(); try { $user_profile = $facebook->api('/me','GET'); echo "Name: " . $user_profile['name']; } catch(FacebookApiException $e) { echo "ERROR"; } } else { //if user is not logged in then get the login user $params = array( 'scope' => 'read_stream, friends_likes, email', 'redirect_uri' => 'http://www.comettea.com', 'display' => 'popup', ); $loginUrl = $facebook->getLoginUrl($params); echo $loginUrl."<br />"; echo "<a target="_blank" href=".$loginUrl."> Login in FB </a>"; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)