-1

我有一个示例代码:

require 'facebook.php';
$facebook = new Facebook(array(
    'appId'  => xxx,
    'secret' => xxx,
    'cookie' => true,
));

$my_url = 'http://didong.net/tru-than.html';
$fpl = "
SELECT post_fbid, fromid, object_id, text, time FROM comment WHERE object_id IN
    (SELECT comments_fbid FROM link_stat WHERE url ='".$my_url."')
";
$params = array(
    'method' => 'fql.query',
    'query'  => $fpl,
);

//Run Query
$result = $facebook->api($params);
print_r($result);

=> 结果是:array()

但是当我浏览器链接https://graph.facebook.com/comments/?ids=http://didong.net/tru-than.html=> 结果有评论

=> 如何运行 fql facebook 查询以获取对此链接的评论?

4

1 回答 1

0
$fql = urlencode(
  "SELECT post_fbid, fromid, object_id, text, time FROM comment WHERE object_id IN   (SELECT comments_fbid    FROM link_stat    WHERE url ='http://didong.net/tru-than.html')"
);

// Run fql query                                                                                    
$fql_query_url = 'https://graph.facebook.com/'.
  '/fql?q='.$fql.
  '&'.$access_token;
$fql_query_result = file_get_contents($fql_query_url);
$fql_query_obj = json_decode($fql_query_result, true);

//display results of fql query                                                                      
echo '<pre>';
print_r("query results:\n\n");
print_r($fql_query_obj);
print_r('Rows: '.count($fql_query_obj['data']));
echo '</pre>';

现场演示:

http://plooza.com/fql/fql_comments.php

于 2012-12-14T20:23:30.787 回答