Dave Burke : Freelance .NET Web Developer specializing in Online Communities

Migrated all of my weblogs.asp.net blog posts. Finally.

I took up this weblog residence in September 2004, but was posting at weblogs.asp.net/dburke since June 2003.  For nearly 5 months I've been wanting to get all of my posts in one location.  Now that its done I have to admit that I am a very happy nerd.

I attempted to do this several times, using BMT 0.1, 0.2 and one or two other migration apps.  But these relied on the dotText ASPNetWeblog.asmx Web Service which has been missing in action at weblogs.asp.net for quite some time.

So in my work with wBloggar and the metablogAPI this past week it struck me that wBloggar was retrieving recent posts, which is what I wanted to do! The question was, how was wBloggar doing it?  Investigating the metablogAPI I quickly discovered XMLRPC and in an hour or so of reviewing Charles Cook's excellent XML-RPC.NET FAQ and sample code I wrote a Winforms XMLRPC client that displayed my recent post titles in a listbox.  Sweeeeet!

From there I went with the BMT 0.1 source and modified how the source blog posts were retrieved, using XMLRPC instead of the Web Service.  I only wanted my posts; I didn't want the categories, and while migrating comments would have been nice, my goal was to grab all of my weblogs.asp.net posts.  Period. 

The core of the migration code follows.  I'll post more on XMLRPC shortly.

private void AddPosts()
{

 IGetRecentPosts proxy = (IGetRecentPosts)XmlRpcProxyGen.Create(typeof(IGetRecentPosts));
// following line retrieves the 329 posts at weblogs.asp.net, the "0" (blogID) value is not used
 Post[] posts = proxy.GetRecentPosts("0", "myusername", "mypassword", 329);  

  foreach(Post post in posts)
 {
  Entry entry = new Entry();
  entry.Title = post.title;
  entry.DateCreated = post.dateCreated;
  entry.Body = post.description;
  entry.EntryID = int.Parse(post.postid.ToString());
  entry.ParentID = -1;
  entry.PostType = PostType.BlogPost;
  entry.PostConfig = (PostConfig)93;
  int entryID = _wsDestination.InsertEntry(entry);
   }
}

 

Comments (0) | Post RSS RSS comment feed

Posted on 2/12/2005 8:30:00 PM by Dave Burke
Categories: .NET
Tags:

Related posts


Powered by BlogEngine.NET 2.0.0.36
Theme by Dave Burke