Facebook 取消了公共 RSS 提要;如何使用新的时间线获取 Facebook 页面 RSS? [英] Facebook killed Public RSS feeds; how to obtain a Facebook Page RSS with the new Timeline?

查看:29
本文介绍了Facebook 取消了公共 RSS 提要;如何使用新的时间线获取 Facebook 页面 RSS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从 Facebook 中提取到 RSS 的页面提要,但是每次我尝试尝试时,我都会在 XML 中收到错误消息,并显示以下内容:

I'm attempting to pull out a page feed to RSS from Facebook, however each time I attempt to try it, I get an error back in the XML with the following :

<![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;
]]>

我使用的网址是:

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

我没有设置年龄限制或国家/地区限制:

I don't have an age restriction set nor a country restriction:

此外,我已经尝试过使用和不使用访问令牌.

Further, I've tried it with and without my access token.

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

As noted in the comments below, the JSON URL is indeed working:

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

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

推荐答案

我遇到了同样的问题.在寻找解决方案后,我发现 FB 默默地扼杀了公共 RSS 支持.(参见 Jesse Stay 的这篇文章)

I got with the same problem. After looking for a solution I found that FB silently killed public RSS support. (see this post from Jesse Stay)

我知道我需要自己调用 API 并构建提要(我还需要通过 WP 插件和其他东西来解析提要.

I understood that I needed to call the API myself and construct the feed (I also need the feed to be parsed by a WP plugin and other stuff.

因此,首先获取 API 密钥(也称为应用程序 ID)并下载 PHP Facebook SDK.

So, first of all get an API key (also called app id) and download the PHP Facebook SDK.

然后下载Universal Feed Generator PHP 类.它将为您生成所有必需的标头和 xml.

Then download the Universal Feed Generator PHP class. It will generate all the required headers and xml for you.

你的 php 脚本将是这样的:

Your php script will be like this:

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 :)

Note from the future (2013-07-09): Don't listen to my answer anymore. It's old. Facebook has a new API with new features on its query language so don't bother pulling feeds. Try to use their API in a more fun, intelligent way :)

这篇关于Facebook 取消了公共 RSS 提要;如何使用新的时间线获取 Facebook 页面 RSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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