Atompub Example File

This is an example atom upload that I'm just testing out. Comments are stripped, so the following wordpress "more" separator is removed


To load this via AtomPub I use cURL, which has a little bit of a strange interface, but it works. The primary section in this file is <content>, which contains the actual post in XHTML.

The rough source for this post can be found in a PDF doc here. You can hack it up for your site and try out atompub. I have done some editting on file to reference it on the WordPress Codex after I uploaded the PDF, thus this file and the PDF are not exactly the same.

See XHTML Entities for those characters that cannot be used in the content body. Generally, it's just &, >, < and ". Everything else seems to be okay.

For some reason wordpress handles newlines like a <br/> so that's a little tricky. I need to figure out a way for wordpress to eat newlines.

  • To add a new post do:

    curl -v -k -u 'user:pass' -H "Content-Type: application/atom+xml" -T "atom-example.xml"
  • To update the current post do:

    curl -v -k -u 'user:pass' -H "Content-Type: application/atom+xml" -X PUT -T "atom-example.xml"<postid>
  • To retrieve the post do:

    curl -v -k -u 'user:pass' https://www.mysite/wp/wp-app.php/post/<postid>

Also, I'm trying to figure out how to format some of the XHTML codes to what I want.
An example using <pre> where <code> ain't
so great:

     main() {
       printf("this is a code fragment");
       // C comment statment
       // Another

I can always change the CSS for these to do what I want when I create my own theme. That's on my todo list.

I wanted to add the XML source for this file as an attachment but it was difficult. I had to
convert the file to either Openoffice ODT, M$ doc or PDF format and then link to it
here. But first I had to figure out the link URI for the attachment, which was a little tricky.

The alternative was to use the The WordPress Editor, with which I'm not that happy. Once one edits a post via the WP editor, it is very difficult to update the post using atompub.

So I used atompub to add the link ref above, One can use the post permalink from the site, or the postid. One interesting note is the link can be relative so the whole can be discarded. That's kind of nice.

Leave a Reply