[英]CodeIgniter Facebook API getuser always 0
我知道這是重復的,但是,我已經嘗試了其他問題中建議的所有內容。
我目前正在獲得重定向循環,因為即使在批准應用程序后,getUser總是返回0。
碼:
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);
}
以下是此應用的設置頁面的屏幕截圖。
https://dl.dropbox.com/u/6647629/facebookapp.png
有時它確實有效,但大部分時間都沒有。
在這里找到解決方案: http : //www.galalaly.me/index.php/2012/04/using-facebook-php-sdk-3-with-codeigniter-2-1/
不得不補充:
parse_str($_SERVER['QUERY_STRING'], $_REQUEST);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.