[英]CodeIgniter Facebook API getuser always 0
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. 我目前正在获得重定向循环,因为即使在批准应用程序后,getUser总是返回0。
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 https://dl.dropbox.com/u/6647629/facebookapp.png
Sometimes it does work, but most of the time it doesn't. 有时它确实有效,但大部分时间都没有。
Found the solution here: http://www.galalaly.me/index.php/2012/04/using-facebook-php-sdk-3-with-codeigniter-2-1/ 在这里找到解决方案: 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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.