Facebook getUser() returns 0 [duplicate] Facebook getUser() returns 0 [duplicate] codeigniter codeigniter

Facebook getUser() returns 0 [duplicate]


I was stuck up with similar issue, here is the solution that may help you.

$facebook = new Facebook(array(  'appId'  => 'xxxx',  'secret' => 'xxxxx',  "redirect_uri" => "set the uri to point to the same page" ));$user = $facebook->getUser();if($user){//your task} else {header('location:'. $facebook->getLoginUrl());}$user = $facebook->getUser();if($user){//your task} else {header('location:'. $facebook->getLoginUrl());

}


Came across a situation where getUser() was returning 0 when it really shouldn't be, the application was still sandboxed. Turns out the user hadn't accept the request to be developer of the application.


I've encountered a similar problem. I used an example project, and couldn't figure out why it keeps returning 0. tried nearly all related links here but none solved it.

The solution was to update Facebook's SDK files in the example project.Simple and easily missed,