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:

Post a Comment

NOTE: Anonymous Commenting has been turned off for a while... The comment spammers are just killing me...

ALL comments are moderated. I will review every comment before it will appear on the blog.

Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...

I reserve, and will use, the right to not approve ANY comment for ANY reason. I will not usually, but if it's off topic, spam (or even close to spam-like), inflammatory, mean, etc, etc, well... then...

Please see my comment policy for more information if you are interested.

Thanks,
Greg

PS. I am proactively moderating comments. Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...