問(wèn)題描述
我正在嘗試從 Facebook 中提取到 RSS 的頁(yè)面提要,但是每次我嘗試嘗試時(shí),我都會(huì)在 XML 中收到錯(cuò)誤消息,并顯示以下內(nèi)容:
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: <a href="https://www.facebook.com/profile.php?id=<FB_ID>">https://www.facebook.com/profile.php?id=<FB_ID></a>
]]>
我使用的網(wǎng)址是:
https://www.facebook.com/feeds/page.php?id=<fb_id>&format=rss20&access_token=<my_page_token>
我沒(méi)有設(shè)置年齡限制或國(guó)家/地區(qū)限制:
I don't have an age restriction set nor a country restriction:
此外,我已經(jīng)嘗試過(guò)使用和不使用訪問(wèn)令牌.
Further, I've tried it with and without my access token.
如下面的評(píng)論所述,JSON URL 確實(shí)有效:
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>
這里發(fā)生了什么/我該如何解決問(wèn)題?
推薦答案
我遇到了同樣的問(wèn)題.在尋找解決方案后,我發(fā)現(xiàn) FB 默默地扼殺了公共 RSS 支持.(參見(jiàn) 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)
我知道我需要自己調(diào)用 API 并構(gòu)建提要(我還需要通過(guò) WP 插件和其他東西來(lái)解析提要.
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 密鑰(也稱(chēng)為應(yīng)用程序 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 類(lèi).它將為您生成所有必需的標(biāo)頭和 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();
來(lái)自未來(lái)的筆記(2013-07-09):不要再聽(tīng)我的回答了.它老了.Facebook 有一個(gè)新的 API,它的查詢(xún)語(yǔ)言有新的特性,所以不要費(fèi)心拉提要.嘗試以更有趣、更智能的方式使用他們的 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 :)
這篇關(guān)于Facebook 取消了公共 RSS 提要;如何使用新的時(shí)間線獲取 Facebook 頁(yè)面 RSS?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!