Importing Haloscan comments into WordPress 2.3 from Blogger

Background

Who knew that when I migrated my Blogger blog to WordPress way back when, I’d still be supporting a hacked together Haloscan importer 3 years later!

Awhile back, I don’t remember if it was during WordPress 2.2 or 2.3, the folks at Google revamped Blogger, which meant the old Blogger importer no longer worked. So the heroic coders that do the heavy lifting for WordPress set out to write the-Blogger-importer-to-end-all-Blogger-importers, this time using Blogger’s feed-based “API”.

The problem for you classic Blogger folk with Haloscan comments is that the only way to link your Haloscan comments to their post is via Blogger’s postID. Which is apparently not accessible in the feed API. Grrr. Which meant my previous hack for associating the postID with the newly imported WordPress post no longer worked.

Last night, I finally went back to the drawing board and came up with a new solution. I’ve tested it successfully on two different blogs.

Step 1: Import your Blogger blog

Nothing to see here. Just follow the instructions in WordPress under Manage > Import.

Step 2: Run Get Blogger postIDs

I wrote a new utility plugin called Get Blogger postIDs that loops through every Blogger-imported post, fetches the old Blogger post, and grabs the postID. In order for this to work, the old Blogger blog must still be web-accessible.

In order for the plugin to find the all-important postID, your Blogger template needs to have Quick Edit links. If it’s a newer, stock template it probably does. If it’s an older or custom template, you may have to add <$BlogItemControl$> to your Blogger template and republish. View source on a published permalink page and search for postID= to find out.

Then follow these instructions:

  1. Download and unzip wp-get-blogger-post-ids-2.0.zip (v2.0)
  2. Upload wp-get-blogger-post-ids.zip to /path/to/wordpress/wp-content/plugins/
  3. Activate the plugin (don’t forget!)
  4. Goto Manage > Get Blogger postIDs
  5. Enter the domain name of your blog (without the http:// or trailing slash). This is going to look like: www.myblogrules.com or myblogrules.blogspot.com
  6. If you have a blogspot.com domain, you can skip the second text box. If you self-host your blogger blog, use the second text box to enter the URL path after the domain, but before the /yyyy/mm/permalink.html, but only if one exists. Common paths include weblog, blogger, and blog. Leave the path blank if there is none.
  7. Click the “Import Blogger postIDs” button

The plugin will print out every post permalink and the Blogger postID it finds. It may take some time to run, depending on the speed of your internet connection and the number of imported posts. Be patient. If something goes wrong, or if you don’t get the domain and path right the first time, don’t worry, you can safely rerun this plugin. It will print “Done!” at the bottom when it’s complete. As always, if you have any problems, leave a comment here.

Thanks to Mike Conover for v2.0 of wp-get-blogger-post-ids.php. It has better feedback messages and a mechanism to specify importing the ids for X posts at a time (useful if your webhost doesn’t like long running php scripts).

Step 3: Run the new import-haloscan.php script

The same prerequisite applies: only “premium” customers have access to Haloscan’s export comments feature. Bah! The only way to get around this limitation and access your comments for export is by donating $12 to Haloscan.

  1. Download and unzip import-haloscan-3.0.zip (v3.0)
  2. Upload import-haloscan.php to /path/to/wordpress/wp-admin/
  3. log in to Haloscan
  4. go to Manage Comments > Export
  5. If you made your $12 donation, there will be an export link for every thousand comments you have. Clicking one of the export links will prompt you to save the file as “export.xml”. If there is more than one link (i.e. if you have more than 1000 comments), rename the first file to export1.xml, the second file to export2.xml, and so on. Save the files to your desktop and upload them to /path/to/wordpress/
  6. In your web browser, go to http://example.com/wordpress/wp-admin/import-haloscan.php replacing example.com/wordpress with the domain name and path to your WordPress install
  7. Click OK at the bottom of the page to import your Haloscan comments

If anything goes wrong, my WordPress Suicide plugin is very handy for deleting all the imported comments and starting over again, without having to reinstall WordPress. Good luck!

relatedposts

22 comments

name
blog (optional)
comment

Thank You a lot!

I’ve just attempted this using your new script, to import comments into a WordPress blog that I converted from iBlog (using Agitprop). It gave me this error message:
Haloscan to WordPress

The importer is running…
XML error: not well-formed (invalid token) at line 9192

What next?

Thanks!

Well Tom, it means there’s a bad character or something on line 9192 of your export.xml file. Best option is to fire up your favorite text editor, open the file, and see if you can’t find and delete the bad character.

Hi Justin,
Everything has worked great so far, except for when I get to the very last step — running the import-haloscan.php script. When I go to the webpage (http://www.tommyandbrea.com/wordpress/wp-admin/import-haloscan.php) I get a HTTP 500 error. Can you help me? Thanks so much!

Nevermind, Justin — I figured out what I was doing wrong. Your plugin ROCKS!!! :) Thanks so much!

Justin, I’ve used several of your other tools without fail, but I can’t get this one to work for anything. When it gets to the final step it says “0 comments imported. Done!” I’ve tried it in different browsers with the same result.

The original blog that I’m trying to import from is http://www.mooreover.com/blogger.php (but I switch to New Blogger and republish to http://www.blogworthy.com whenever I need to import or export). Any ideas?

Jesse, did the “Get Blogger postIDs” plugin run successfully? You can check by looking at the custom fields for one of your Blogger imported posts to see if there’s a postID entry alongside the old post permalink entry.

A friend of mine was able to do it by adding some snippets of code. Thanks the tool though - saved over four years of comments for me!

Hmm for some reason I seem to be having the same problem as Jesse - There are no “postid” custom fields in the imported posts after running wp_get_blogger_ids (although it goes through all the posts perfectly)

Kev, hmm, I’m probably going to need more info to help you troubleshoot. Like the URLs of your current blog and your Blogger blog to be imported. Feel free to shoot me an email if you’d like to troubleshoot over IM.

What was confusing was the Plugin part where you download the Get Blogger postIDs.

* upload the plugin file Get Blogger postIDs into your wp-content/plugins directory

I didn’t know i was supposed to put that file in that directory, since i am a wordpress newbie, so that little extra hint would have helped, but i am still greatful for your help justin. Thanks!

Also, it would have helped if i could have landed on this webpage FIRST for wordpress 2.3 and not the older 1.5 and 2 versions. unfortunately, when i googled how to import haloscan to wordpress, it landed on the older page first. Well anyway, after several hours of searching i found it.

JUSTIN’S WP COMMENT IMPORT FOR DUMMIES.

STEP 1: import blogger blog
STEP 2: DOWNLOAD GET BLOGGER POSTIDS AND UPLOAD TO wp-content/plugins directory.
STEP 3: SIGN IN TO WORDPRESS
STEP 4: CLICK ON PLUGIN LINK
STEP 5: ACTIVATE GET BLOGGER POSTIDS
STEP 6: WAIT FOR IT TO SAY DONE
STEP 7: SIGN IN TO HALOSCAN
STEP 8: MANAGE COMMENTS
STEP 9: EXPORT COMMENTS
(pay 12 bucks to haloscan to upgrade account if necessary)
STEP 10: DOWNLOAD EXPORT.XML FILE FROM HALOSCAN
STEP 11: UPLOAD EXPORT.XML FILE TO YOUR MAIN WORDPRESS DIRECTORY WHERE ALL YOUR WP FILES ARE LOCATED. (/wordpress/ or maybe /blog/)
STEP 12: GO TO http://example.com/wordpress/wp-admin/import-haloscan.php
(replace above example w/ your information)
STEP 13: CLICK GO
STEP 14: PRAY TO GOD
STEP 15: if it does not work, ask questions here i guess?

Matt, thanks for your comments and suggestions. I’ve rewritten the “Step 2: Run Get Blogger postIDs” with more explicit instructions.

Okay, I’ve got everything else correct…I just can’t seem to figure out where to put the export file. Sigh. Any suggestions?

Scratch that - now I figured out where to put export. Now I’m having the same problem as Jesse. All my post IDs are correct, but the comment importer is still saying “Done. 0 comments imported.” Any advice?

Feel free to shoot me an email, maybe we can do some troubleshooting.

The importer throws this error when I run it:

XML error: not well-formed (invalid token) at line 8461

I have 9 export files from Haloscan, named as you suggested. Is the error in one of them?

Ok, now I got it working more or less, but now I get a fatal error saying that the plugin exceeds the 30 secs run-time for plugins.

Ok, NOW I got it (sorry for all the comments!).
If one has a lot of comments, say 9 export files or more, run them one at a time.
In step 5.3 you only upload one file at a time, for instance export1. Once they have been imported, remove the export file and upload export2, run the script, remove the file and so on. Otherwise you get a fatal error.

Thank you, Justin - you saved my 8500 comments :D

FANTASTIC!! Thanks so much for this! You might want to include Emme’s comment below in the instructions, though. I had the same problem and uploaded ALL the export files (I had 10) instead of uploading each one then running the script, upload the next and run the script, etc. Thanks a million!!

Not sure if I’m using this correctly, but…

I’ve imported my Blogger blog (after other headaches!) and run the first stage of the conversion. It seems successful with the program listing as far as I can tell all of my posts and saying it’s got a number for each.

However… I have Haloscan active on the blog (I thought I’d use it as an intermediary before actually doing the conversion) and it’s picking up no comments from the existing HaloScan archive. On checking the links, WordPress is still using the Post_IDs from the Blogger conversion i.e. they start at 1 and work up to 955.

I had a check of the code for the “get-blogger-post-ids” and as far as I can work out, it should be getting said IDs and putting them into the post and postmeta tables? Sorry, but my PHP isn’t that great so excuse me if that’s wrong!

As such, I’d have expected the Haloscan links to work. Either way, I’ve had a browse through my WordPress DB using phpmyadmin and there seems to be no sign of the Blogger post IDs in there anywhere.

I’m using WP2.5 if this makes a difference. Any help appreciated as I have 4500 comments I’d really like to drag over!

Sorry, on further investigation it’s supposed to add a meta-tag(?) called “blogger_id” and the populate that with the ID it’s imported? Thing is, I still can’t find any reference to these using phpmyadmin. Maybe I’m looking in the wrong place :)

I could always try and adapt your script so that it updated the existing post IDs with the ones from the import…