[英]Jquery (jfeed) - Origin xxxxx is not allowed by Access-Control-Allow-Origin
I'm using jFeed to try to retrieve a Facebook page's RSS feed.我正在使用jFeed尝试检索 Facebook 页面的 RSS 提要。 I can manually navigate to the RSS just fine ( https://www.facebook.com/feeds/page.php?format=atom10&id=12345 ) but when I try to use the following code, I end up with the error "Origin xxxxx is not allowed by Access-Control-Allow-Origin."
我可以手动导航到 RSS 就好了( https://www.facebook.com/feeds/page.php?format=atom10&id=12345 )但是当我尝试使用以下代码时,我最终得到错误“Origin Access-Control-Allow-Origin 不允许 xxxxx。”
jQuery.getFeed({
url: 'https://www.facebook.com/feeds/page.php?format=atom10&id=12345',
success: function (feed) {
alert(feed.title);
}
});
I'm assuming this is due to it requiring OAuth 2.0, but I really need a "silent" solution so people don't have to have a Facebook account or interact with Facebook in any way.我假设这是因为它需要 OAuth 2.0,但我确实需要一个“静默”解决方案,这样人们就不必拥有 Facebook 帐户或以任何方式与 Facebook 交互。
You might take a look at https://github.com/dawanda/jquery-rss .您可以查看https://github.com/dawanda/jquery-rss 。 It's using google's feed API.
它使用谷歌的提要 API。
Just got it working.,!刚开始工作.,! I'm using the app ID and secret code to get the access_token and then using the jquery getJSON method to get the data.
我使用应用程序 ID 和密码获取 access_token,然后使用 jquery getJSON 方法获取数据。 Works like a charm, no facebook auth required!!!
像魅力一样工作,不需要 facebook 身份验证!!!
appID = '' //myappid
secretCode = '' //app "secret code"
authURL = 'https://graph.facebook.com/oauth/access_token?client_id=' + appID + '&client_secret=' + secretCode + '&grant_type=client_credentials'
feedURL = 'https://graph.facebook.com/' + appID + '/feed?'
function getFeed() {
$.get(authURL, function (accessToken) {
$.getJSON(feedURL + accessToken, function (data) {
$.map(data.data, function (item) {
alert(item.message);
//type: status, photo
//likes.count
//from.name
//created_time
});
});
});
};
Obviously you'd want to do something besides "alert", but it works.显然,除了“警报”之外,您还想做一些其他事情,但它确实有效。 Quite simple compared to anything else I've found.
与我发现的任何其他东西相比非常简单。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.