Saturday, October 22, 2005

Blogger Backup with Tortuga Blogger 2.0 .NET Component

Not having a life, I just gave the Open Intelligence Data ™/Tortuga Blogger 2 .Net component that I posted about here, Free Blogger 2.0 .NET Component, a quick try.

The MSI was a simple file copy and appears to be safe. I do need to run reflector on it to confirm there’s nothing bad in there though (said after I’ve already used the component… Dogh!)

Using it is very easy. And it could almost be perfect as a Blogger backup. The only problem is that it can only access your last 100 posts!

Damn, so close. And it’s almost perfect too. The BlogPost.SaveToXml is great. It does seem to have an nbsp issue, so the XML won’t load into IE. But that’s easy enough to solve.

All I need is a way to get my TotalPosts and then a method to get a post by TotalPostIndex. I wonder if this is a problem with the Blogger API and not this component? Time to do more R&D. I’d really rather use the API to backup my blog instead of spidering it…  

Anyway, below is a very quick and dirty VB7.1 code snip that shows how to use Tortuga Blogger 2 .Net component to log into Blogger, get your first blog and download to xml all your recent posts (up to the most recent 100).

    Dim Blogger As New Tortuga.Blogger

    Blogger.LoginName = "Put your Blogger User ID Here"
    Blogger.Password = "Put your Blogger Password Here"

    If Not Blogger.Login Then
      MsgBox(Blogger.LoginFailReason)
      Blogger.Dispose()
      Return
    End If

    Dim blog As Tortuga.Blog = Blogger.GetBlogByIndex(0) 'Get 1st blog
    If blog Is Nothing Then
      Blogger.Dispose()
      Return
    End If

    blog.DownloadRecentPosts()

    Dim RecentPostCount As Integer = blog.NumPosts

    For BlogPostIndex As Integer = 0 To RecentPostCount - 1

      Dim blogpost As Tortuga.BlogPost = blog.GetPost(BlogPostIndex)

      blogpost.SaveToXmlFile("C:\test\" & BlogPostIndex.ToString("000") & ".xml")

      blogpost.Dispose()

    Next

    MsgBox("Done")
    blog.Dispose()
    Blogger.Dispose()

No comments: