Not a developer? Go to MovableType.com

Documentation

Retrieving a list of blogs

To retrieve a list of blogs associated with a user’s account via Atom, one need only perform an authenticated HTTP GET against the requisite URL corresponding to each Six Apart product.

Introspection Document Format

The document retrieved contains a set of link relations. For each weblog associated with the user’s account you will find five link elements. Below is a list of the link relations associated with each weblog, and what the corresponding URL can be used for:

  • service.feed - this link points to the Atom feed associated with the weblog. Fetching this link will return an Atom feed containing a list of entries. This Atom feed is often public and does not require authentication.
  • service.categories - this links points to the Atom endpoint from which a list of categories can be retrieved. This endpoint requires authentication.
  • service.upload - this link points to the Atom endpoint to which photos can be uploaded. This endpoint requires authentication.
  • service.post - this link points to the Atom endpoint to which any Atom request to create, read, update or delete an entry can be sent. This endpoint requires authentication.
  • alternate - this link points to the weblog’s homepage in HTML format. This endpoint is often public and does not typically require authentication.

Endpoint URLs

The weblog introspection document can be retrieved from any instance of Movable Type. If the web interface can be accessed by visited the following URL:

http://www.somedomain.com/cgi-bin/mt/mt.cgi

Then the introspection document can be retrieved by visiting the following URL:

http://www.somedomain.com/cgi-bin/mt/mt-atom.cgi/weblog

Sample Request

GET /cgi-bin/mt/mt-atom.cgi HTTP/1.1
Host: www.myhost.com
X-WSSE: my credentials

Sample Response

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

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://purl.org/atom/ns#">
  <link xmlns="http://purl.org/atom/ns#" 
        type="application/x.atom+xml" rel="service.post" 
        href="http://www.typepad.com/t/atom/weblog/blog_id=64534" 
        title="SOAP::Lite"/>
  <link xmlns="http://purl.org/atom/ns#" 
        type="application/x.atom+xml" 
        rel="service.feed" h
        ref="http://www.typepad.com/t/atom/weblog/blog_id=64534" 
        title="SOAP::Lite"/>
  <link xmlns="http://purl.org/atom/ns#" 
        type="application/x.atom+xml" 
        rel="service.upload" 
        href="http://www.typepad.com/t/atom/weblog/blog_id=64534/svc=upload" 
        title="SOAP::Lite"/>
  <link xmlns="http://purl.org/atom/ns#" 
        type="application/x.atom+xml" 
        rel="service.categories" 
        href="http://www.typepad.com/t/atom/weblog/blog_id=64534/svc=categories" 
        title="SOAP::Lite"/>
  <link xmlns="http://purl.org/atom/ns#" 
        type="text/html" 
        rel="alternate" 
        href="http://www.soaplite.com/" 
        title="SOAP::Lite"/>
</feed>

Perl Code Sample

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

my $api = XML::Atom::Client->new;
$api->username(prompt("Enter your TypePad username:"));
$api->password(prompt("Enter your TypePad password:"));

sub get_weblogs {
   my $blogs;
   my $feed = $api->getFeed("http://www.typepad.com/t/atom/weblog");
   my @links = $feed->link();
   foreach my $l (@links) {
         my ($id) = ($l->href =~ /blog_id=(\d+)/);
         foreach my $l (@links) {
           my ($id) = ($l->href =~ /blog_id=(\d+)/);
           $blogs->{$id}->{$l->rel} = $l->href;
         }
         $blogs->{$id}->{'title'} = $l->title;
   }
   return $blogs;
}

my $blogs = get_weblogs($api);
foreach my $id (keys %$blogs) {
      $blog = $blogs->{$id};
      print "Weblog #".$id."\n";
      foreach my $key (keys %$blog) {
        print " $key = ".$blog->{$key}."\n";
      }
}

sub prompt {
      my ($msg) = @_;
      print "$msg ";
      my $in = <STDIN>;
      chomp $in;
      return $in;
}
Back