Facebook杀死了公共RSS订阅,如何使用新的时间线获取Facebook页面的RSS?

13
我想从Facebook获取页面Feed并转换成RSS,但每次尝试时,我都会在XML中收到以下错误信息:
<![CDATA[
This feed URL is no longer valid. Visit this page to find the new URL, if you have access: &lt;a href=&quot;https://www.facebook.com/profile.php?id=<FB_ID>&quot;&gt;https://www.facebook.com/profile.php?id=<FB_ID>&lt;/a&gt;
]]>

我使用的URL是:

https://www.facebook.com/feeds/page.php?id=<fb_id>&format=rss20&access_token=<my_page_token>

我没有设置年龄限制或国家限制:
enter image description here

此外,我已经尝试了有和没有我的访问令牌。

如下面的评论所述,JSON网址确实有效:

https://graph.facebook.com/<page_name>/feed&https://www.facebook.com/<page_name>/‌​feed?access_token=<token>

这里发生了什么 / 我该如何解决这个问题?


如果不知道页面ID,我们无法查看您的问题 - 页面是否可以在https://graph.facebook.com/<PAGE ID>访问? - Igy
1
是的,它返回一个包含正确信息的 JSON 代码块。 - ylluminate
然后前往 Facebook 页面,查看是否有更新的 RSS 源链接。我拥有的页面给出以下链接:feed://www.facebook.com/feeds/page.php?id=PAGE_ID_GOES_HERE&format=rss20 - Igy
2
这里还有一个不错的教程:http://ahrengot.com/tutorials/facebook-rss-feed/ - Eric Leroy
有没有办法将这种方法扩展到我们的个人动态更新中? - user556433
显示剩余4条评论
5个回答

23

6
当我尝试使用个人资料ID访问图形URL(上述第2步)时,返回"error": {"message": "需要用户访问令牌来请求此资源。", "type": "OAuthException", "code": 102}。他们限制了这种访问还是与隐私设置有关? - Dan
这种方法存在一个小问题。非拉丁语言内容的字符编码。 - SaidbakR
4
该方法已被弃用,因此此方法不再起作用。 - Kenton de Jong

14

我也遇到了同样的问题。经过寻找解决方法,我发现Facebook已经悄悄地取消了公共RSS支持。(请参见Jesse Stay的这篇文章)。

我明白我需要自己调用API并构建反馈(我还需要让WP插件和其他东西解析反馈)。

首先获取API密钥(也称为应用程序ID),然后下载PHP Facebook SDK。

然后下载通用Feed生成器 PHP类。它将为您生成所有所需的标题和XML。

您的php脚本将如下所示:

require('lib/facebook.php'); // require your facebook php sdk
include("feed_generator/FeedWriter.php"); // include the feed generator feedwriter file

$fb = new facebook(array(
    'appId' =>  'YOUR_APP_ID', // get this info from the facebook developers page
    'secret'=>  'YOUR_SECRET_KEY' // by registering an app
));
$response = $fb->api('/spreetable/feed','GET'); // replace "spreetable" with your fb page name or username

// create the feedwriter object (we're using ATOM but there're other options like rss, etc)
$feed = new FeedWriter(ATOM);

$feed->setTitle('Spree Table'); // set your title
$feed->setLink('http://spreetable.com/facebook/feed.php'); // set the url to the feed page you're generating

$feed->setChannelElement('updated', date(DATE_ATOM , time()));
$feed->setChannelElement('author', array('name'=>'Spree Table')); // set the author name

// iterate through the facebook response to add items to the feed
foreach($response['data'] as $entry){
        if(isset($entry["message"])){
            $item = $feed->createNewItem();
            $item->setTitle($entry["from"]["name"]);
            $item->setDate($entry["updated_time"]);
            $item->setDescription($entry["message"]);
            if(isset($entry["link"]))
                $item->setLink(htmlentities($entry["link"]));

            $feed->addItem($item);
        }
}

// that's it... don't echo anything else, just call this method
$feed->genarateFeed();

来自未来的提示(2013-07-09):请不要再听我的回答了,因为它已经过时了。Facebook推出了一个新的API,其查询语言具有新功能,因此不要费力拉取信息源。尝试以更有趣、更智能的方式使用他们的API :)


非常感谢您的启示。您是否知道目前有哪些WordPress插件正在集成这个功能? - ylluminate
不是我知道的。我正在使用http://feedwordpress.radgeek.com/,但为此我需要将Feed作为Atom、RSS或类似格式。也许创建一个WP插件是个好主意=) - lu1s
同意,这是某人窃取这个领域的绝佳机会。 - ylluminate

2

2

哪一个?两个都对我有效。 如果这是你的问题,你需要在第二个URL中的“id=”后附加你从第一个站点获得的ID。 - antou
将我的 Facebook ID 给第一个链接总是显示错误信息! - Mayur R. Amipara
你需要输入页面的网址(例如 http://www.facebook.com/thisIsMyNameOnFacebook),然后就可以得到ID。 - antou
我知道这是编辑文本中的提示,但我无法在https://www.facebook.com/MatthewSantoroOfficial上获取它。不管怎样,我找到了替代解决方案。您建议的网站向我显示错误**无法查找Facebook数字ID。请再试一次,并仔细检查您个人Facebook个人资料页面的URL。** - Mayur R. Amipara
哦,奇怪,我以前从未遇到过这个问题。好的 :) - antou

0

寻找页面 ID 更简单的方法:

只需查看您的 FB 页面(或时间轴应用程序,以前称为选项卡)的源代码,并搜索 page_id。将其替换为提供的代码即可。


请不要在您的文本中放置任何签名 - 您的用户框就在旁边。 - Sven

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接