FB PHP SDK: $facebook->getUser() always returning 0

Posted: December 13, 2012 in Facebook SDK
Tags: ,


Facebook PHP SDK: $facebook->getUser() always returning 0.
To solve this problem, i use accessToken in my code:

1. In your form,

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

$access_token = $facebook->getAccessToken(); //get access token

<form ...>
<input type="hidden" name="access_token" value="<?php echo $access_token; ?>">
</form>


2. In your process form, set the access token.

$facebook->setAccessToken($_POST['access_token']);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s