使用 jquery 将 facebook 页面提要作为 json [英] get facebook page feed as json with jquery
问题描述
我一直在尝试使用 jquery 从 json 数据中获取 Facebook 页面提要.到目前为止,我已经能够使用我的方法获取页面详细信息,但是当我尝试获取页面的提要时,它给了我一个错误,并且在控制台中显示语法错误:标签无效".这是我的代码.....
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);
});
我还用整个代码创建了一个 jsfiddle.如果需要,请查看 -> http://jsfiddle.net/yZn7N/.如果我转到指定的链接,我可以看到所有的 json 数据并且它们确实被获取,但我不确定是什么导致了无效标签错误.任何形式的帮助修复或解释为什么会发生这种情况将不胜感激.
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.
推荐答案
您需要使用 Facebook Graph API 来实现这一点.
You need to use the Facebook Graph API for this to happen.
https://developers.facebook.com/docs/reference/api/page/#feed
您的呼叫应更改为:
https://graph.facebook.com/237173582992285/feed?access_token=YOUR-TOKEN-GOES-HERE
您可以尝试使用这个测试页面,并尝试熟悉图形api.
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
您还可以从页面以多种格式获取墙.
You can also get the Wall from the page in several formats.
JSONhttps://www.facebook.com/feeds/page.php?format=json&id=237173582992285
原子https://www.facebook.com/feeds/page.php?format=atom10&id=237173582992285
RSShttps://www.facebook.com/feeds/page.php?format=rss20&id=237173582992285
这篇关于使用 jquery 将 facebook 页面提要作为 json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!