3
工作我使用Facebook的使用CodeIgniter
和工作正常 但突然停止工作,是Facebook的改變任何東西Facebook登錄與笨突然停止
Facebook的功能
public function takofacebook($page = TRUE, $name = TRUE) {
if (isset($page) and (($page != TRUE) or ($page != 1)) and isset($name)) {
$data['page'] = $page;
$data['name'] = $name;
}
$this -> load -> library('fb');
if (!$this -> fb -> is_connected()) {
redirect($this -> fb -> login_url(current_url()));
}
$fb_user = $this -> fb -> client -> api('/me');
if (empty($fb_user)) {
$error = "FACEBOOK LOGIN FAILED - USER US EMPTY. FILE: " . __FILE__ . " LINE: " . __LINE__;
$this -> session -> set_flashdata('register_error', $error);
} else {
$this -> user -> set_facebook_id($fb_user['id']);
$user = $this -> user -> get_by_facebook();
if (!empty($user) && !empty($user -> id) && is_numeric($user -> id)) {
//TODO: Make things a bit more secure here
//Login & Redirect home
$this -> _login($user -> id, 'facebook');
$this -> load -> view('users/redirect_home2', $data);
return;
}
}
//Go to the registeration page
$this -> load -> view('users/redirect2', array('method' => 'facebook'));
}
/**
* Logs user in with facebook
*/
//tako facebook
public function zangafacebook() {
$this -> load -> library('fb');
if (!$this -> fb -> is_connected()) {
redirect($this -> fb -> login_url(current_url()));
}
$fb_user = $this -> fb -> client -> api('/me');
if (empty($fb_user)) {
$error = "FACEBOOK LOGIN FAILED - USER US EMPTY. FILE: " . __FILE__ . " LINE: " . __LINE__;
$this -> session -> set_flashdata('register_error', $error);
} else {
$this -> user -> set_facebook_id($fb_user['id']);
$user = $this -> user -> get_by_facebook();
if (!empty($user) && !empty($user -> id) && is_numeric($user -> id)) {
//TODO: Make things a bit more secure here
//Login & Redirect home
$this -> _login($user -> id, 'facebook');
$this -> load -> view('users/redirect_home3');
return;
}
}
//Go to the registeration page
$this -> load -> view('users/redirect3', array('method' => 'facebook'));
}
很明顯,你有自己的Facebook庫(也許這個庫正在與官方SDK通信/擴展),請確保你有最新的[SDK版本](https://github.com/facebook/facebook-php -sdk),還嘗試添加圖api調用'$ fb_user = $ this - > fb - > client - > api('/ me');'嘗試catch語句以捕獲任何潛在的錯誤。 – ifaour