如何获取RSS Feeds订阅数
RSS(简易资讯聚合)是一种消息来源格式规范,用以发布经常更新资料的网站,例如部落格文章、新闻、音讯或视讯的网摘。
在使用feedburner来生成RSS Feeds时,考虑到页面布局的需要,我们需要自定义显示RSS Feeds订阅数。
1. 新建rss.php,代码如下:
<?php
//get feedburner count
$whaturl="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=hvdesigns";
//Initialize the Curl session
$ch = curl_init();
//Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//Set the URL
curl_setopt($ch, CURLOPT_URL, $whaturl);
//Execute the fetch
$data = curl_exec($ch);
//Close the connection
curl_close($ch);
$xml = new SimpleXMLElement($data);
$fb = $xml->feed->entry['circulation'];
//end get feedburner count
2. 在需要显示RSS Feed数的页面需要包含(include)rss.php
<?php include("rss.php"); ?>
3. 显示订阅数的代码
<?php echo $fb;?>