php – Facebook杀死公共RSS源;如何使用新的时间轴获取Facebook
发布时间:2020-12-13 16:32:12 所属栏目:PHP教程 来源:网络整理
导读:我试图从Facebook上提取RSS的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
我试图从Facebook上提取RSS的RSS,但是每次尝试尝试时,我会在
XML中返回以下错误信息:
<![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> ]]> 我使用的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>/??feed?access_token=<token> 这里发生了什么/如何解决问题?
我遇到同样的问题.寻找解决方案后,我发现FB默默地杀死了公共的RSS支持. (见Jesse Stay的
this post)
我明白,我需要自己调用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(); 未来的注意事项(2013-07-09):不要再听我的回答了.老了Facebook有一个新的API,其查询语言具有新功能,因此不要打扰提取.尝试使用他们的API更有趣,聪明的方式:) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |