Not a developer? Go to MovableType.com

Documentation

Retrieving an atom entry

To retrieve a single entry on a weblog in Atom format, one first needs to discover the URI from which to retrieve the entry. This URI is easily discovered by inspecting an Atom feed. Each <entry> element should contain a link relation entitled “service.edit”. By performing an HTTP GET against this URI, one will be able to retrieve a complete Atom representation of that post or resource.

Finding the service.edit URI for an Entry

The following demonstrates where in an Atom feed document one can find the URI that a client can then fetch a complete representation of an Atom resource contained within that feed. The following is an excerpt from an Atom feed document:

<feed xmlns="http://www.w3.org/2005/Atom" 
  xmlns:thr="http://purl.org/syndication/thread/1.0">
  <title>majordojo</title>
  <entry>
    <title>Implementing James Snell&apos;s Atom Thread Extension</title>
    <link rel="alternate" type="text/html" 
      href="http://www.majordojo.com/2006/01/implementing_ja.php" />
    <link rel="service.edit" type="application/atom+xml"
      href="http://www.somedomain.com/mt/mt-atom.cgi/weblog/blog_id=3/entry_id=1066" 
      title="Implementing James Snell's Atom Thread Extension" />
    <published>2006-01-20T05:02:47Z</published>
    <updated>2006-01-20T05:23:19Z</updated>

Notice the element:

<link rel="service.edit" type="application/atom+xml"
   href="http://www.somedomain.com/mt/mt-atom.cgi/weblog/blog_id=3/entry_id=1066" 
   title="Implementing James Snell's Atom Thread Extension" />

The href attribute points to the URI from which you can retrieve a complete representation of this post. Once you have this URI, a client can then perform an HTTP GET against that URI to retrieve a complete Atom representation of the corresponding resource.

Sample Request

GET /t/atom/weblog/blog_id=1/entry_id=3 HTTP/1.1
Host: www.typepad.com
X-WSSE: my credentials

Sample Response

HTTP/1.1 200 Content-Type: application/x.atom+xml

<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://purl.org/atom/ns#">
  <title>My First Post</title>
  <content mode="xml">Contents of my post</content>
  <issued>2003-10-23T18:35:51Z</issued>
  <link rel="alternate" type="text/html" href="http://example.typepad.com/weblog/2003/10/my_first_post.html" />
  <id>tag:typepad.com,2003:post-3</id>
  <link rel="service.edit" href="http://www.typepad.com/t/atom/weblog/blog_id=1/entry_id=3" title="My First Post" type="application/x.atom+xml" />
</entry>

Sample Perl Code

#!/usr/bin/perl
# Code sample for retrieving Atom weblog entries - this is a trivial
# example, and in someways a lot more work than is necessary.
# After all, the feed contains all the data that is necessary, there is
# no need to fetch the feed and then fetch each entry individually...

use XML::Atom::Client;
use XML::Atom::Entry;

my $BLOG_ID = '131501';
my $USERNAME = 'your username';
my $PASSWORD = 'your password';

my $api = XML::Atom::Client->new;
$api->username($USERNAME);
$api->password($PASSWORD);

my $FeedURI = 'http://reesespieces.typepad.com/majordojo/atom.xml';

my $feed = $api->getFeed($FeedURI);
my @entries = $feed->entries;
foreach my $entry (@entries) {
    my @links = $entry->link();
    my $EditURI;
    foreach my $l (@links) {
        if ($l->rel eq 'service.edit') {
            $EditURI = $l->href;
        }
    }
    my $e = $api->getEntry($EditURI);
    print $e->title . "\n";
}
Back