Facebook杀死了公共RSS源; 如何使用新的时间轴获取Facebook Page RSS?

yll*_*ate 13 php ruby rss facebook facebook-graph-api

我正试图从Facebook中提取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;
]]>
Run Code Online (Sandbox Code Playgroud)

我正在使用的URL是:

https://www.facebook.com/feeds/page.php?id=<fb_id>&format=rss20&access_token=<my_page_token>
Run Code Online (Sandbox Code Playgroud)

我没有年龄限制集也没有国家/地区限制:
在此输入图像描述

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

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

https://graph.facebook.com/<page_name>/feed&https://www.facebook.com/<page_name>/??feed?access_token=<token>
Run Code Online (Sandbox Code Playgroud)

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

小智 23

这是我的指示.

  1. 转到Facebook并右键单击配置文件图像以获取URL并复制ID
  2. 到这里https://graph.facebook.com/ID_GOES_HERE
  3. 获取结果页面上列出的ID值并进行复制
  4. 转到此处并粘贴新ID https://www.facebook.com/feeds/page.php?id=ID_GOES_HERE&format=rss20
  5. 将网址复制并粘贴到您的Feed阅读器中

  • 我得到{`"error":{"message":"需要用户访问令牌才能请求此资源.","type":"OAuthException","code":102}}`当我尝试访问图表时具有配置文件ID的URL(上面的步骤2).他们是否限制此访问权限,还是与隐私设置相关? (6认同)
  • 这已不再适用,因为此方法已被弃用. (4认同)

lu1*_*u1s 13

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

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

因此,首先获取API密钥(也称为app id)并下载PHP Facebook SDK.

然后下载Universal Feed Generator 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();
Run Code Online (Sandbox Code Playgroud)

未来的注意事项(2013-07-09):不要再听我的回答了.它太老了.Facebook有一个新的API,其查询语言具有新功能,所以不要费心去拉动Feed.尝试以更有趣,更智能的方式使用他们的API :)