Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook PHP 3.0.1 SDK API, getUser() always == 0! Why?

Tags:

facebook

I have the following code:

$facebook = new Facebook(array(
    'appId' => '###',
    'secret' => '###'
));
$user = $facebook->getUser();

$user is ALWAYS 0, my AppId and Secret are both 100% correct. What am I doing wrong?

like image 246
josef.van.niekerk Avatar asked Aug 01 '11 21:08

josef.van.niekerk


2 Answers

make sure that you have an if condition to check for user status

$user=$facebook->getUser();
if($user)
//someactions
else
{
// redirect the user to login and authorize your application, if necessary
header('Location:'.$facebook->getLoginURL());
}

Please check the case of functions. I may be wrong.

like image 180
Joby Joseph Avatar answered Nov 19 '22 05:11

Joby Joseph


Just chek in your facebook Your FB Application Admin Panel if you put the right website url... LOCALHOST for testing purpose or your http://www.YOURWEBSITE.com

like image 31
Jean-Christophe Duperron Avatar answered Nov 19 '22 06:11

Jean-Christophe Duperron