Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('facebook-php-sdk-master/src/base_facebook.php');
- require_once('facebook-php-sdk-master/src/facebook.php');
- // Credentials
- $fb_app_id = '324097137728196';
- $fb_app_secret = 'e67f4a3eaed41bd9167643efb3ecac39';
- $facebook = new Facebook(array('appId'=>$fb_app_id, 'secret'=>$fb_app_secret, 'cookie'=>true));
- // Permissions
- $allow = 'email,user_status';
- $loginurl = $facebook->getLoginUrl(array('scope'=>$allow/*, 'display'=>'popup'*/));
- $get_fb_user = $facebook->getUser();
- // Offline
- if (is_null($get_fb_user) or $get_fb_user == 0) {
- header("Location: {$loginurl} ");
- exit;
- // Online
- } else {
- try {
- // Verify
- $facebook->api($get_fb_user);
- // Token
- $service_token = $facebook->getAccessToken();
- // User Details
- $fql = "SELECT uid, email, username, name, pic_square, locale FROM user WHERE uid = me()";
- $user = $facebook->api(array('method'=>'fql.query', 'query'=>$fql));
- echo '
- <ul>
- <li>User id: '.$user['0']['uid'].'</li>
- <li>User email: '.$user['0']['email'].'</li>
- <li>User name: '.$user['0']['name'].'</li>
- <li>User username: '.$user['0']['username'].'</li>
- <li>User locale: '.$user['0']['locale'].'</li>
- </ul>';
- $nameuser = $user['0']['name']
- $url = "http://graph.facebook.com/$nameuser/picture?type=large";
- $headers = get_headers($url, 1);
- if( isset($headers['Location']) ) {
- echo '<img src='.$headers['Location'].'>';
- //copy($headers['Location'],'obernardovieira.jpg');
- }
- else {
- echo "ERROR";
- }
- } catch (FacebookApiException $e) {
- header("Location: {$loginurl} ");
- exit;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement