doujiao1905 2010-04-24 21:06 采纳率: 100%
浏览 7
已采纳

获得feedburner订户的数量?

I'm currently using this code to get the number of subscribers to my blog:

$whaturl="http://api.feedburner.com/awareness/1.0/GetFeedData?uri=http://feeds.feedburner.com/DesignDeluge"; 
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $whaturl);
$data = curl_exec($ch);
curl_close($ch);
$xml = new SimpleXMLElement($data); 
$fb = $xml->feed->entry['circulation'];

but when I echo $fb it doesn't work (the whole file that $fb is being echoed on doesn't appear). Any ideas on why this isn't working?

  • 写回答

1条回答 默认 最新

  • doufen5175 2010-04-24 21:12
    关注

    If you take a look at $data before trying to load it with SimpleXMLElement, you'll see it contains the following portion of HTML code :

    <HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
    <TITLE>301 Moved</TITLE></HEAD><BODY>
    <H1>301 Moved</H1>
    The document has moved
    <A HREF="http://feedburner.google.com/awareness/1.0/GetFeedData?uri=http://feeds.feedburner.com/DesignDeluge">here</A>.
    </BODY></HTML>
    

    So, there's no way you'll find what you're looking for in there ;-)


    A solution could be to use the CURLOPT_FOLLOWLOCATION option (see curl_setopt), so curl follows redirections...

    ... But this doesn't seem to work either.


    Actually, when I try to load the URL that's given in the portion of HTML code I posted earlier :

    http://feedburner.google.com/awareness/1.0/GetFeedData?uri=http://feeds.feedburner.com/DesignDeluge
    

    I only get the following XML as return :

    <?xml version="1.0" encoding="utf-8" ?>
    <rsp stat="fail">
        <err code="2" msg="This feed does not permit Awareness API access" />
    </rsp>
    


    Are you sure you are using the right URLs / feeds ?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作