【问题标题】:How do I use the Posterous API for reading posts?如何使用 Posterous API 阅读帖子?
【发布时间】:2009-12-17 19:17:10
【问题描述】:

我想使用http://posterous.com/api/readposts?hostname=NAMEOFSITE的API调用从我的Posterous博客中提取博客内容

在网络浏览器中输入上述地址时,返回XML格式的内容。

我坚持的是如何使用或将这些内容存储在一个数组中,以便我可以使用 PHP 以我想要显示的格式输出它?

【问题讨论】:

    标签: php api blogs posterous


    【解决方案1】:

    【讨论】:

      【解决方案2】:

      我为我的post.ly helper 应用程序所做的正是您想要实现的。它使用 SimpleXML 来解析 Posterous API 调用的结果,并显示带有 post.ly 链接和视图数量的帖子列表:

      $root = simplexml_load_string($xml);
      foreach ($root->post as $node)
      {
       $url = $node->url;   
       $date = date("Y-m-d H:i", strtotime($node->date));
       $title = $node->title;
       $views = $node->views;
       echo "$date - <a href=\"$url\">$title</a> ($views views)<br />\n";
      }
      

      如果有兴趣,请查看我的应用程序的simplified source code

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多