Reputation: 384
I know this is a duplicate, however, I've tried pretty much everything suggested in the other questions.
I'm currently getting a redirect loop because getUser is always returning 0, even after approving the app.
Code:
public function auth() {
$user = $this->facebook->getUser();
if ($user) {
$user = $this->facebook->api('/me');
if (!$this->Users->getByID($user["id"])) {
$this->data->needsRegister = true;
} else {
$toSetInSessions = new stdClass();
$toSetInSessions->authed = 1;
$dbUser = $this->Users->getByID($user["id"]);
foreach ($dbUser as $key => $value) {
$toSetInSessions->user->$key = $value;
}
$this->session->set_userdata($toSetInSessions);
redirect("/");
}
} else {
$params = array('scope' => 'email,read_friendlists');
if ($_SERVER['HTTP_USER_AGENT'] != "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)") {
redirect($this->facebook->getLoginUrl($params));
}
}
$this->load->view('header', $this->data);
$this->load->view('auth', $this->data);
$this->load->view('footer', $this->data);
}
Here is the screenshot of my settings page for this App.
https://dl.dropbox.com/u/6647629/facebookapp.png
Sometimes it does work, but most of the time it doesn't.
Upvotes: 0
Views: 1938
Reputation: 384
Found the solution here: http://www.galalaly.me/index.php/2012/04/using-facebook-php-sdk-3-with-codeigniter-2-1/
Had to add:
parse_str($_SERVER['QUERY_STRING'], $_REQUEST);
Upvotes: 2