我在 facebook 上有一个应用程序,它给了我以下错误:
Fatal error: Call to a member function api() on a non-object in
/public_html/user/fbmin.php on line 7
这是代码:
try{ //here's line 7:
$userdata= $facebook->api('/me');
//request for user friends in app
$frienddata=$facebook->api(array(
'method' => 'fql.query',
'query' => 'SELECT uid, name FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user = 1'
));}
catch (FacebookApiException $e) {
error_log($e);
$userdata = null;
$frienddata= null;
}
奇怪的是,我在另一个页面上使用了相同的代码并且一切正常,我尝试通过编写使 $facebook 全球化
GLOBAL $facebook;
在 try 语句之前,它仍然给出相同的错误,可能是什么问题?