Requires user session error while using FQL in facebook

断了今生、忘了曾经 提交于 2019-12-06 12:27:26

问题


I am making a fb app and this is what I need to do:

I get the page id of a business page and I need to get the admin_id of the page. I am using the following code and I get the error message which I have copied at the end.

Can anyone kindly help me ? Thanks.

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>";
}

error message:

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:


Problem while executing Facebook query

the answer is provided here,

we need to write the following lines...

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

thanks :)



来源:https://stackoverflow.com/questions/4174938/requires-user-session-error-while-using-fql-in-facebook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!