How do I use the Posterous API for reading posts?

1.4k Views Asked by At

I want to extract the blog content from my Posterous blog using the API call of http://posterous.com/api/readposts?hostname=NAMEOFSITE

When entering the above address in a web browser, it returns the content in XML format.

What I'm stuck on is how I can use or store this content in an array so I can output it using PHP in the format that I want to display it in?

2

There are 2 best solutions below

0
On BEST ANSWER
1
On

I did exactly what you are trying achieve for my post.ly helper application. It uses SimpleXML to parse the result of the Posterous API call and display a list of posts with post.ly links and number of views:

$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";
}

Check out the simplified source code of my application if interested.