FQL Query returns empty array
I recently included the facebook comments widget on my site, and now I would like to, on another page tell how many comments each 开发者_JS百科post on my site has. My code looks like this:
$facebook = new Facebook(MY_API_KEY,MY_SECRET_KEY);
$result = $facebook->api(array(
'query' => 'SELECT text FROM comment WHERE xid=3',
'method' => 'fql.query'));
print_r($result);
If I run that same FQL query on this page: http://developers.facebook.com/docs/reference/rest/fql.query/ it works, but when run on my site it returns an empty array.
Thanks in advance!
You're mixing front end documentation with back end implementation. The link you posted is more for implementation in javascript.
You should be creating and instance of Facebook like this:
$facebook = new Facebook(array('appId'=> MY_API_KEY, 'secret'=> MY_SECRET_KEY));
That may be your problem, you may not be getting and authenticated instance of Facebook. The constructor function only takes 1 parameter.
精彩评论