我如何回应Facebook的图形API?

时间:2012-04-29 22:54:32

标签: facebook facebook-graph-api

我想在我的网站中显示来自:https://graph.facebook.com/comments/?ids=http://lujanventas.com/test.php的内容。

除了AJAX调用之外我该怎么做?可以在没有JS的情况下完成吗?

1 个答案:

答案 0 :(得分:1)

您可以创建一个服务器端脚本来读取文件的内容并回显它

这是php中这样的脚本的一个例子:

 $ids = "http://lujanventas.com/test.php";
 $url = "https://graph.facebook.com/comments/?ids=".urlencode($ids);
 $data = json_decode(file_get_contents($url),true);
 foreach($data[$ids]["comments"]["data"] as $comment){
     echo $comment["message"]."<br /><br />";
 }