Problem with Facebook Api login $ user not returning properly

When I run this code and my cookies have been cleared and I am not registered on facebook. He directs me to facebook and I log in, but when he brings me back to my page, it is the same where, as the profile picture should be shown, etc ....

I, apparently, narrowed down the problem of the return statement from $ user because it returns 0. I looked at this code for a long time and I did not find what I was doing wrong.

What I need to change in order to get it so that when I get back from facebook login, it will show pic profile and so on ...

<?php

require_once 'libs/facebook.php';
require 'connections/connection.php';

// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
            'appId' => 'xxxxxxxxxxxxx',
            'secret' => 'xxxxxxxxxxxxxxxx',
        ));

// Get User ID
$user = $facebook->getUser();
echo $user;

if ($user) {
    try {
        // Proceed knowing you have a logged in user who authenticated.
        $user_profile = $facebook->api('/me');
        echo $user;
    } catch (FacebookApiException $e) {
        error_log($e);
        $user = null;
    }
}

// Login or logout url will be needed depending on current user state.
if ($user) {
    //$logoutUrl = $facebook->getLogoutUrl();
    $logoutUrl = $facebook->getLogoutUrl(array('next' => ($fbconfig['baseurl'] . 'logout.php')));
} else {
    $statusUrl = $facebook->getLoginStatusUrl();
    $loginUrl = $facebook->getLoginUrl(array(
        'scope' => 'user_about_me',
        'scope' => 'read_friendlists'
            ));
}
?>   
+2
source share
1 answer

, , . DEMO, .

, . , PHP SDK only.So, , ​​ - .

: .

base_facebook.php makeRequest() .

$opts = self::$CURL_OPTS;  

$opts[CURLOPT_SSL_VERIFYPEER] = false;  

- http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/

+1

All Articles