我将一个简单的登录/注册脚本(使用 facebook 连接)转换为 oop。但是现在当我调用 getUser() 时出现错误:
Fatal error: Call to a member function getUser() on a non-object
有人知道我该如何解决吗?谢谢。附言。包括 facebook sdk。
private $facebook;
private $db;
public function __construct($db_user, $db_password, $db_name, $db_host, $app_id, $secret)
{
if (empty($_SESSION)) {
$this->facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $secret,
'cookie' => true
));
$this->db = new ezSQL_mysql($db_user, $db_password, $db_name, $db_host);
} else {
$this->Redirect('index.php');
}
}
public function Login()
{
$session = $this->facebook->getUser();
}