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

I have the following code:

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

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

+6
source share
3 answers

make sure you have an if condition to check 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 function case. Maybe I'm wrong.

+4
source

Just say β€œFB Application Control Panel” on your facebook if you post the correct site URL ... LOCALHOST for testing purposes or your http://www.YOURWEBSITE.com

+1
source

I had the same problem ... And I just managed to solve this problem by fixing the problem with my session

0
source

Source: https://habr.com/ru/post/894066/


All Articles