0
votes

I am getting an issue while trying to auth user through the graph API with the official php sdk.

Look simple as hell but I can not get it to work and getUser() keep returning null.

Here is my code reduced in the most simple form:

$facebook = new Facebook(array(
      'appId'  => 'ID',
      'secret' => 'SECRET',
      'cookie' => true
    ));

    $user = $facebook->getUser();

    if (!$user):
       $params = array('scope' => 'email','redirect_uri' => 'http://myredirecturi.com');
     ?>
        <a href=" <? echo $facebook->getLoginUrl($params); ?>">Login</a>
    <? endif; ?>

So when I click the login button I go to facebook and them I arrived on the redirect url like it should be.

I also have GET data: "code" and "state" so it is looking good, however I don't have a "signed_request" value.

Finally, $facebook->getUser() keep returning null.

What is wrong here ?

-Is the facebook object well initialized ? (should the 'cookie' setting be set to true ?)

-The redirect_uri is also not an https uri. Does it matter ?

-Should I look for something in the facebook app settings ?

Thanks !

2
Having the same issue, described in here: stackoverflow.com/questions/7140162/… - Marcin Bobowski
So did your problem was solved ?? - Snehasish

2 Answers

2
votes

Good answer here not sure if it is the same issue for you but worked for me. Basically until the user authorizes the app you can't get their Uid. So even if they are logged in the app still doesn't have access until they accept. Then UID will be returned. facebook->getUser() returns 0

1
votes

If anyone else still has this issue, make sure your app still isn't in sandbox mode :)