我试图第一次运行FQL。这是我在index.php文件中包含的代码:
<?php $query="SELECT message FROM status WHERE uid = 544337058";echo $query; ?>
<?php
include_once ('facebook.php');
$api_key = 'XXXXXXXXXXXXXXX';
$secret = 'XXXXXXXXXXXXXXXXX';
global $facebook;
$facebook = new Facebook($api_key, $secret);
$result = $facebook->api_client->fql_query($query);
?>
<?php echo $result?>
我已从另一个标签登录到facebook,只是尝试阅读我自己的状态消息。但是我收到以下错误:
SELECT message FROM status WHERE uid = @@@@@@
Fatal error: Uncaught exception 'FacebookRestClientException' with message 'Requires
user session' in /users/home/aafhe7vh/web/public/facebookapi_php5_restlib.php:3065 Stack
trace: #0 /users/home/aafhe7vh/web/public/facebookapi_php5_restlib.php(1025):
FacebookRestClient->call_method('facebook.fql.qu...', Array) #1 /users/home/aafhe7vh
/web/public/status.php(46): FacebookRestClient->fql_query('SELECT message ...') #2 {main}
thrown in /users/home/aafhe7vh/web/public/facebookapi_php5_restlib.php on line 3065
如何获取并向此查询提供用户会话。
感谢。
答案 0 :(得分:1)
尝试在require_login
对象之后放置$facebook
方法,例如它应该是:
$facebook = new Facebook($api_key, $secret);
$facebook = $facebook->require_login();
如果它似乎是facebook应用程序,也将此行放在require_login
下面:
$facebook = $facebook->require_frame();