在Facebook中使用FQL时需要用户会话错误

时间:2010-11-13 21:53:46

标签: facebook facebook-fql

我正在创建一个fb应用程序,这就是我需要做的事情:

我获取了商家页面的页面ID,我需要获取该页面的admin_id。我使用以下代码,我收到了最后复制的错误消息。

有人可以帮助我吗?感谢。

include_once 'facebook.php';

$facebook = new Facebook($api_key, $secret);

//$page_ids == page_id of a business/fan page  

$query="SELECT uid from page_admin where page_id =".$page_ids.";";

$admins =$facebook->api_client->fql_query($query);

foreach ($admins as $jerry) {
  echo $jerry['uid']."<br>";
}

错误消息:

Fatal error: Uncaught exception 'FacebookRestClientException' with message 'Requires user session' in /var/www/seanpeace/data/www/racersnation.com/facebookTest/facebookapi_php5_restlib.php:3112 Stack trace: #0 /var/www/seanpeace/data/www/racersnation.com/facebookTest/facebookapi_php5_restlib.php(1025): FacebookRestClient->call_method('facebook.fql.qu...', Array) #1 /var/www/seanpeace/data/www/racersnation.com/facebookTest/profile.php(64): FacebookRestClient->fql_query('SELECT uid from...') #2 {main} thrown in /var/www/seanpeace/data/www/racersnation.com/facebookTest/facebookapi_php5_restlib.php on line 3112

1 个答案:

答案 0 :(得分:1)

Problem while executing Facebook query

答案在这里提供,

我们需要写下以下几行......

$ facebook = new Facebook($ api_key,$ secret); $ facebook = $ facebook-&gt; require_login(); $ facebook = $ facebook-&gt; require_frame();

谢谢:)