Take the 2-minute tour ×

When I run this code, and my cookies have been cleared and I am not logged into facebook. It directs me to facebook and I log in but when it brings me back to my page it is the same, where as it should be show me profile pic and so on...

I seem to have narrowed down the problem of the return statement of the $user because it returns a 0. I have stared at this code for a long time and I havent found what I am doing wrong.

What do i need to change to get it so that When i return from logging in from facebook it will show the profile pic and so on...


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

$facebook = new Facebook(array(
            'appId' => 'xxxxxxxxxxxxx',
            'secret' => 'xxxxxxxxxxxxxxxx',

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

if ($user) {
    try {
        echo $user;
    } catch (FacebookApiException $e) {
        $user = null;

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'
share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Not to worry my friend, you are not doing anything wrong. I'm having same issue with my DEMO application which was running alright till yesterday.

I'm sure you are having issue with getting access token as well. I think issue is with PHP SDK only.So probably will be fixed in some time.

SOLUTION : This worked for me after trying for many solutions for this issue.

In base_facebook.php file, find the makeRequest() method and check for following Line.

$opts = self::$CURL_OPTS;  

Immediately following it, add this line

$opts[CURLOPT_SSL_VERIFYPEER] = false;  

More details can be found here - http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/

share|improve this answer
Perhaps you should open a bug report with Facebook. That way you'd be able to include a link in this post. –  Lix Dec 27 '13 at 11:08
Well I'm not exactly affected by this issue. so I'm fine with it for now. but thank you for showing concern :) –  Trimantra Software Solution Dec 27 '13 at 11:09
That's not really what you said in your answer. I feel like this should be a comment and not an answer - it doesn't really contain any information. You're just saying "me too". –  Lix Dec 27 '13 at 11:10
I realize that you're just trying to help. But I don't feel that this post is really helpful nor constitutes an answer. –  Lix Dec 27 '13 at 11:11
I do understand that but when I made this post. I was not allowed to post a comment and hence I had to write an answer. –  Trimantra Software Solution Dec 27 '13 at 11:24
show 2 more comments

Your Answer


