用jquery获取Facebook页面Feed作为json [英] get facebook page feed as json with jquery

查看:178
本文介绍了用jquery获取Facebook页面Feed作为json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图通过jQuery来从json数据中获取Facebook页面。到目前为止,我已经能够通过我的方法获取页面详细信息,但是当我尝试获取页面的feed它给我一个错误,在控制台中它说语法错误:无效的标签。这是我的代码.....

  $ .getJSON(https://www.facebook.com/feeds/ page.php?id = 237173582992285& format = json& callback =?,function(results){
console.log(results);
});

我也创建了一个jsfiddle与整个代码。如果需要,请查看 - > http://jsfiddle.net/yZn7N/
我可以看到所有的json数据,如果我去指定的链接,他们得到提取,我不知道是什么导致无效的标签错误。任何一种帮助修复或解释为什么会发生这种情况将非常感激。

解决方案

您需要使用Facebook图API为此发生。



https://developers.facebook.com/docs/reference/api/page/#feed



您的来电应更改为:



https: //graph.facebook.com/237173582992285/feed?access_token=YOUR-TOKEN-GOES-HERE



您可以尝试使用此测试页面,并尝试熟悉图表api。



https://developers.facebook.com/tools/explorer/?method=GET&path=237173582992285%2Ffeed



编辑:



您还可以从页面获取几种格式的墙。



JSON
https://www.facebook.com/feeds/page.php?format=json&id=237173582992285



ATOM
https://www.facebook.com/feeds/page.php?format=atom10&id=237173582992285



RSS
https://www.facebook.com/feeds/ page.php?format = rss20& id = 237173582992285


I have been trying to get facebook page feed from json data with jquery. so far I have been able to get page details with my method but when I try to get page's feed it gives me an error and in the console it says "syntax error: invalid label". this is my code.....

    $.getJSON("https://www.facebook.com/feeds/page.php?id=237173582992285&format=json&callback=?", function(results){
    console.log(results);
});

I also have created a jsfiddle with the whole code. check it out if required -> http://jsfiddle.net/yZn7N/. I can see all the json data if I go to the specified link and they do get fetched and I'm not sure what's causing the invalid label error. Any kind of help fixing it or explanation of why this is happening will be gratefully appreciated.

解决方案

You need to use the Facebook Graph API for this to happen.

https://developers.facebook.com/docs/reference/api/page/#feed

Your call should change to:

https://graph.facebook.com/237173582992285/feed?access_token=YOUR-TOKEN-GOES-HERE

You can try use this test page and try to familiarize with the graph api.

https://developers.facebook.com/tools/explorer/?method=GET&path=237173582992285%2Ffeed

EDIT:

You can also get the Wall from the page in several formats.

JSON https://www.facebook.com/feeds/page.php?format=json&id=237173582992285

ATOM https://www.facebook.com/feeds/page.php?format=atom10&id=237173582992285

RSS https://www.facebook.com/feeds/page.php?format=rss20&id=237173582992285

这篇关于用jquery获取Facebook页面Feed作为json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆