简体   繁体   English

使用Graph API获取Facebook帖子

[英]Fetch Facebook posts using Graph API

How to retrieve this information and show it in our website? 如何检索此信息并将其显示在我们的网站上?

I've tried this but no luck, please help. 我已经尝试过了,但是没有运气,请帮忙。

The problem is related to $.getJSON . 问题与$.getJSON As the documentation states, the request can not successfully retrieve data from a different domain, subdomain, or protocol. 文档所述,请求无法成功从其他域,子域或协议检索数据。

I don't see you mention a language you want to use in order to get those posts, but here are 2 simple examples of how to do it using: 我看不到您提到要用来获得这些帖子的语言,但是这里有两个简单的示例,说明了如何使用:

  • PHP: PHP:

$info = json_decode(file_get_contents('https://graph.facebook.com/cocacola/posts')); $ info = json_decode(file_get_contents('https://graph.facebook.com/cocacola/posts'));;

 if ($info) { foreach ($info->data as $obj) { echo $obj->message, "<br/>"; } } 
  • javascript: JavaScript的:
 <script src="http://connect.facebook.net/en_US/all.js"></script> <script type="text/javascript"> FB.api('/cocacola/posts', function(response) { for (var i = 0; i < response.data.length; i++) { alert(response.data[i].message); } }); </script> 

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM