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

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

问题描述

我试图从Facebook上提取一个页面的RSS给RSS,但是每次尝试尝试时,我都会在XML中返回一个错误:

 <![CDATA [
此Feed网址不再有效。访问此页面以查找新网址(如果您有访问权限):& lt; a href =& quot; https://www.facebook.com/profile.php?id =< FB_ID&& quot;& ; GT; HTTPS://www.facebook.com/profile.php ID = LT; FB_ID>&安培; LT; / A&安培; GT;?
]]>

我使用的URL是:

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

我没有年龄限制和国家限制:



此外,尝试使用和不使用我的访问令牌。



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

  https://graph.facebook.com/<page_name>/feed&https://www.facebook.com/<page_name>/喂?=的access_token <令牌GT; 

这里发生了什么/如何解决问题? / p>

解决方案

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



我明白,我需要自己调用API并构建Feed(我还需要一个由WP插件和其他东西解析的feed。 >

所以,首先得到一个API密钥(也称为应用程序ID)并下载PHP Facebook SDK。



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



您的PHP脚本将如下所示: p>

  require('lib / facebook.php'); //要求您的Facebook php sdk 
include(feed_generator / FeedWriter .php); //包含feed生成器feedwriter文件

$ fb = new facebook(array(
'appId'=>'YOUR_APP_ID',//获取此信息从Facebook开发者页面
'secret'=> 'YOUR_SECRET_KEY'//通过注册一个app
));
$ response = $ fb-> api('/ spreetable / feed','GET'); //用你的fb页面名称或用户名替换spreetable

//创建feedwriter对象(我们正在使用ATOM,但还有其他选项,如rss等)
$ feed =新FeedWriter(ATOM);

$ feed-> setTitle('Spree Table'); //设置你的标题
$ feed-> setLink('http://spreetable.com/facebook/feed.php'); //将URL设置为您生成的Feed页面

$ feed-> setChannelElement('updated',date(DATE_ATOM,time()));
$ feed-> setChannelElement('author',array('name'=>'Spree Table')); //设置作者名称

//通过Facebook回复来迭代添加项目到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);
}
}

//是这样的...不要回应任何其他东西,只需调用这个方法
$ feed-> genarateFeed();

未来注意事项(2013-07-09):不要再听我的回答了。老了Facebook拥有一个新的API,其查询语言具有新功能,因此不要打扰提取。尝试以更有趣,聪明的方式使用他们的API:)


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

The URL I'm using is:

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.

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>

What is going on here / how do I resolve the problem?

解决方案

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)

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.

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

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

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();

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 Page RSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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