Lukášův bloček

Random photos, thoughts and notes 
« Back to blog

Posterous API for C# (and VB.NET)

Let me introduce my latest creation - Posterapi - a C# wrapper for Posterous API, complete with source code and samples!

Few months ago (see here), I discovered there was most likely no usable and free C# wrappers for Posterous API. So I decided to write one myself. It took me two months, but the first beta has just been released today

Check out Posterapi homepage and sample code for more information, or just download the latest binaries and samples or the source code (MIT-style license). All currently available features except Posterous Twitter API are implemented (let me know if you would like to have that as well).

To publish a new post with 2 photos, a simple code like this can be used:

// Initialize an authenticated posterous session
    PosterousSession session = new PosterousSessio(email, password);

    // Construct a new post and attach two photos
    PosterousNewPost newPost = new PosterousNewPost();
    newPost.Title = "New post!";
    newPost.Body = "This is the body of the new post.";
    newPost.Tags = "posterous, api, photo";
    newPost.Files.Add("photo1.jpg");
    newPost.Files.Add("photo2.png");

    // Publish the post to the primary site (blog)
    PosterousPostInfo postInfo = session.PublishPost(0, newPost);

    // Display some information about the new post
    Console.WriteLine("Published as {0}", postInfo.ShortUri);

There are more samples - even a GUI posting application that is very useful for posting long videos that are not really suitable for e-mail submission.

I have to say that Posterous API doesn't really make it easy to put a nice .NET API on top of it. The available methods seem to be a random selection of its functionality. Some key functionality (at least in my opinion) is missing. Some examples:

  • Even if you know an ID of a single post, you can't easily download it.
  • If you know its post.ly shortcode, you can only download it if it's public - even if you are authenticated.
  • You have to know a Posterous hostname of a site to be able to download its posts. If you only know its custom domain (like lukas.pokorny.eu), there is no way to determine its Posterous hostname (pokorny.posterous.com).
  • Only "basic" authentication is currently available. This is not secure because the password is transferred in near-plaintext.

This means that if you feel that some part of Posterapi is not pretty, it might not necessarily be my fault ;-)
Of course, if you find something you really don't like or if something is not working as expected, please let me know. This is still a beta and I only tested the features I actually need. Report all the bugs here.

If you find this useful, please let me know!

Comments (16)

Jan 20, 2010
By the way, this is not the only C# Posterous API wrapper available - René Stain was faster than me and released his own closed-source wrapper library just few days ago: http://blog.renestein.net/Projekt+C+Posterous+API+Ndash+Verze+0001+Alfa.aspx
Jan 21, 2010
René Stein said...
Thanks for the link.
I was not aware of your project and effort, but two distinct libraries are always better than one.;)

BTW: In return - I added info about your library - http://tinyurl.com/yleh8ej

Feb 03, 2010
Ervin Ter said...
Nice job
Feb 09, 2010
Daniel David said...
Thanks, I used your wrapper for a week or so with no problems - until today - when suddenly (without me changing any code) I got a mysterious error which crashed the app.
I have 2 lines
1) PosterousSession posterous = new PosterousSession("isaacmozeson.posterous.com");

2)PosterousPostCollection posts = posterous.GetPosts(0, 0, 3);

(to get the first 3 posts)

the program complains about line 2:
Exception Details: System.Exception: xxx

any ideas?

Feb 10, 2010
René Stein - thanks a lot and sorry for misspelling your name! I noticed you are still slightly ahead and already implemented a Posterous backup utility. Good job! :-)

Daniel David - this is a bug in a routine that was supposed to fix the strange HTML returned by Posterous. Sadly, it's also the only exception for which I forgot to write a proper exception message (and choose a proper exception type)... Thanks for reporting this issue! I just fixed it and released a new version, please get it from http://nuane.com/posterapi/ and give it a try!

Feb 19, 2010
amhed said...
Thanks! this was really helpful!
Feb 28, 2010
sherifeldin said...
C# Posterous wrapper returns PosterousException: Node not found error when users submit from emails because the <posterous:author> node is not part of the XML.
hope you could fix that in the next release.
Thanks
Mar 06, 2010
Thanks sherifeldin! I just fixed this, but don't have any time to test it at the moment, so if it still doesn't work, let me know.
I moved the project to Google Code - http://code.google.com/p/posterous-dotnet-api/ - that's where you can download the current build and report any bugs.
Mar 16, 2010
Roger Peters liked this post.
Apr 06, 2010
Tin180 .com said...
Thanks! Your lib is very helpful for me.
Apr 16, 2010
Steve Woods said...
Hey man, I just wanted to say thanks for your excellent work on this wrapper for C# - I've used it to build my site, take a look > http://www.swoo.co.uk/

One thing - when will it be possible to retrieve the tags associated with a specific post? I noticed that you can retrieve all tags, site-wide, but there is no such functionality such as "mypost.PosterousPostTags()".

Anyway, nice work mate - thanks a lot!

Oct 27, 2010
Matt Wakeman said...
Any plans for Silverlight Mobile support?
Jan 28, 2011
ananthg said...
I tried the sample and did not work the PosterousSession.CS is trying to load an HTML Doc that has 500 internal server error. Can you give me some pointers on what might I be doing wrong?

Aprreciate your help.

Mar 12, 2011
ullfindsmit said...
The Posterious-DotNet-API on google code does not work.
The other Czech post only has DLL so cant use that either.
Nov 23, 2011
david lee said...
sorry, this dll does not work now.
when i create a new post, it shows:
--------------------------------------
Untreated System.Xml.XmlException
Message = "start tag on line 6" link "and the closing tag" head "does not match the line 15, position 5."
Source = "System.Xml"
LineNumber = 15
LinePosition = 5
--------------------------------------
Could you check it please?
Nov 27, 2011
The problem encountered by ananthg, ullfindsmit and david lee is almost certainly caused by the fact that Posterous revamped their API and only few of their old API calls still work. Publishing new posts certainly doesn't :-(

Unfortunately, I no longer have motivation (or time) to continue developing and maintaining a C# Posterous API library. Dead simple blogging platform was all I wanted and all I needed. Too bad it didn't work for Posterous. But Posterous Spaces does not work for me - the simplicity is gone and I just don't need another Facebook.

However, all the Posterous API source code I published is free - If anyone would like to take over the project at Google Code, just let me know!

Leave a comment...