Import Blogger Beta to WordPress

This page is outdated. Please click here for the update. Comments are closed on this post.

As I have not heard anything about the solution to this problem, I wrote a script. This script is a simple but powerful 😉 script which extracts the posts and comments from RSS feeds at blogger.com.

Instructions:

Copy the script to your main WordPress directory and run it (http://your.name/blogger-beta-import.php). The options are self-explanatory. This means you can customize the category and user before importing.

Warning:

This script represents a security hazard if left on the server. Once you are finished, delete it. Don’t even rename or save a copy on the server. The script does not honor WordPress authentication and checks, but utilizes some of WordPress’ functions.

Limitations:

  • No handling of images (stay on blogger server)
  • Comments will have the names but not email or URL – limitation with RSS from Blogger
  • Unlikely to work if you use other comment systems
  • You need to enable RSS feed for comments – very important!

As for images, they will stay in blogger.com but I suggest you download them at once to your server as Blogger does not allow hot-linking (images will be blocked). You don’t have to do it one by one, you can use this plugin by Notions: Blogger Image Import. I’ve tried it and it worked well. One thing is that it depends on CURL to download images – servers without this extension will not execute the script. Let me know as I have a workaround for this, provided that your PHP version is later than 4.3.0.

Please don’t look at the code as it is written in 2 hours without so many cosmetic or improvements in efficiency. This script will work on existing WordPress installations but due to some assumptions made, it may break certain things like post counts for categories, etc. I suggest use it only on a virgin WordPress installation. However, I’ve tried it to import several different blogs and the result is awesome – it looks like multi-user blog 🙂

This code will be short-lived, I think as Blogger is finalizing their system out of Beta. One little change on their system would mean disaster for this script, and I am not sure I will have the time to give any kind of support. So, be quick and import now, while the script still works!

I have not tested this script with blogs larger than 300, if you encounter problems do let me know, maybe we can split executions.

Download the script here:

blogger-beta-import.zip (2.81KB)
blogger-beta-import-0.2.zip (3.64KB)
blogger-beta-import-0.3.zip (3.69KB)
blogger-beta-import-0.4.zip (4.86KB)
blogger-beta-import-0.5.zip (4.94KB)

Changelog:

2006-12-22:

  • Added ability to add commentor URL and email since these data can’t be obtained from RSS.
  • Added extra checks to terminate script if something fails. No use wasting user time to wait for a broken result.

2007-01-01:

  • Bugfix: When a comment author’s name contains apostrophes it will fail to be loaded into the database. Update 0.3 fixed that – thanks to Dawn.

2007-01-11:

  • Added automated checking for feed retrieval mechanism (fopen or curl). If both are not available, the script will tell you and not run 😉
  • Added code for retrieval using curl.
  • Added ability to make step by step imports – useful for people having bandwidth or server speed problems. Requested by Dawn.
  • This script has only been tested in few sites, so if you encounter any problems do let me know.

2007-01-14:

  • Bugfix: First import does not work, page have to be refreshed to make it work – thanks to Jonas.

I suggest you download the script only from this site, especially if you’re not a programmer as PHP codes are easily modifiable for malicious intent.

I will not be liable for any problems you might have with your WordPress installation. Use this script at your own risk.

Comments are welcome but I may take some time to respond as my time is limited.

How to make sure full feeds are available:

Switch to Advanced Mode and make sure your settings are like this:

Blogger Feed Settings

Special Notes:

Thanks to Charles Wesley for his suggestions on using the CURL library.

Tested On WordPress versions:

  • 2.0.5 – Working.
  • 2.0.6 – Working.
  • 2.0.7 – Working.
  • 2.1 – Working. Thanks to Ricardo

TODO:

  • Import by a number of posts at a time (staged import) – done
  • Haloscan import support
  • Mapping of categories from blogger
  • Mapping of authors from blogger
  • As a plugin
  • Include an option to import all posts without staging
  • Maintain permalinks from blogger
0 Shares

160 thoughts on “Import Blogger Beta to WordPress”

  1. Hi Ady!

    Ive been trying your recent script and it works flawlessly! Thanks.

    Are you planning on adding categories export function?

  2. @Norm: I tried importing your blog into my development server and it worked fine. Maybe you can put

    <?php phpinfo(); ?>

    in a test.php file, upload it to your destination server email me the URL so that I can analyze it.

    @ricardo: I was not aware that blogger has categories? Point me to a blogger blog that implements this and I’ll let you know whether it is possible.

  3. Have tried running this script a few times and no matter wether I choose 5 or 100 posts the first cycle imports perfectly and as soon as I click the next button I get an error message containing the following…

    PHP Warning: fopen(): php_network_getaddresses: gethostbyname failed in..

    I checked (via test.php) and allow_url_fopen is set to on.

    my blogspot ID is everythingspukka.

    Any idea on why the script is failing on my webhost?

    Thanks

  4. Hi… Thanks for the great script. I am wondering however, if you had your blogger hosted on your own domain instead of having the blogspot.com address how will this script work?

    Can anyone please advise? Thanks so much in advance!

  5. @pukkalad: The fopen is allowed, but was having trouble solving the hostname to IP. Please check your server config. Does it happen all the time (when you try again)?

    @ricardo: Thanks. I shall have a look when I have time

    @Jen: You need to republish the blog inside blogger, and then enable full feeds like Liana did (comment #47-49)

  6. Any chance you have a mod for this script to import blogger run sites that aren’t hoested in the “yourdoain.blogspot.com” set up? So the address is just “yourdomain.com” instead. Just wondering, as the blog i have to import stretches well over 1000 posts, and repblishing that is painful indeed. Nice script btw.

  7. I seem to be getting a little error when I replace the old script with your script on the “Import” page. Immediately upon clicking on “Import” I see an error such as this:

    Warning: require_once(./wp-config.php) [function.require-once]: failed to open stream: No such file or directory in /home/.mart/jimimorrison/jimimorrisonshead.com/wp-admin/import/blogger-beta-import.php on line 47

    Fatal error: require_once() [function.require]: Failed opening required ‘./wp-config.php’ (include_path=’.:/usr/local/php5/lib/php’) in /home/.mart/jimimorrison/jimimorrisonshead.com/wp-admin/import/blogger-beta-import.php on line 47

    Any help?

  8. @bass: Nope. Unless Google wants to hire me for such function 😉

    @NL: I am not sure about the feeds if you host it on your own server. I will try have a look.

    @Jimi: You uploaded it into /wp-admin/import/ which is the wrong place. You need to upload it to / (the root directory)

  9. Hi Ady,

    The staged import seems to be working OK on my blog now.

    I see the Haloscan import is on your TODO list. I’ve been looking at how the script works on my blog and have a couple of thoughts (NB – my ignorance of PHP and MySQL is pretty total, so please forgive me if I’m seizing the wrong end of the stick here).

    Each item in the RSS feed includes the following:

    <guid isPermaLink=’false’>tag:blogger.com,1999:blog-6524248.post-5071682647612674547</guid>

    The 19-digit number after “.post-” is the ID used by Haloscan to match comments with each post. All I need is a way to insert that as an HTML comment in each imported post, and then this script can pick things up from there.

    I notice your script does refer to this blogpost ID at line 302 – though does the “+6” mean it only looks at the first six digits of the post ID? As noted above, the post ID is 19 digits long.

    In any event, when I look at the actual MySQL tables, there is a column for “guid” but no data appears under this. Which seems to suggest the “guid” data is not getting imported for some reason.

    So as I see it there are two things involved here:

    (1) make sure the guid field for each item is imported from the RSS feed; and

    (2) insert that as a comment in each field.

    Apologies if I am totally missing the point here, but if not I hope this helps.

  10. Here’s the error I am getting. I get this after it does the first 100 posts.

    Warning: fopen() [function.fopen]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/mythough/public_html/blogger-beta-import.php on line 247

    Warning: fopen(http://.blogspot.com/feeds/posts/full?alt=rss&max-results=1&start-index=200000) [function.fopen]: failed to open stream: Success in /home/mythough/public_html/blogger-beta-import.php on line 247

    ERROR: [] Unable to extract initial data from http://.blogspot.com/feeds/posts/full?alt=rss&max-results=1&start-index=200000

  11. @ricardo: Thanks

    @John: +6 is to strip “.post-” which is 6 characters, so the whole guid is taken.

    @Lisa, pukkalad: I think you guys share the same problem. Please create a text file named something.php, with the following contents:

    <?php phpinfo(); >

    upload it on the server and pass me the URL (maybe via email?). I suspect there’s some kind of settings that prevent sessions to be stored.

  12. i keep getting an error message for the curl extension. i cant seem to install it….that is if I have the right file. did you say you had a workaround? most, if not all of my images were links from flickr anyway.

  13. @John: +6 is to strip “.post-” which is 6 characters, so the whole guid is taken.

    Oops. Told you I was ignorant…

    But that doesn’t alter the fact that the guid apparently isn’t being taken.

  14. @justin: Please refer to comment #38

    @John: point taken. It’s not saved as there was no obvious use for it, and now we have a reason to import it as well.

    I am very busy this week with a couple of projects in hand and work itself so I appreciate everyone’s understanding.

  15. Thanks for doing all this work.

    I’m keen to try out this script, but I know previous blogger imports have failed to preserve permalinks as Blogger truncates the title much sooner than WordPress (less than 40 characters in length), excludes English article words (a, an, the) and drops characters with accents, instead of converting them to their closest ASCII equivalent.

    Is this a problem here?

  16. Hi,

    Thanks for the plugin.

    However I am getting the following errors when downloading my blogger beta posts.

    I have a lot 1415, so the number of posts might be causing the problems.

    I am getting the following errors:

    Fatal error: Maximum execution time of 30 seconds exceeded blogger-beta-import.php line 144

    and

    Fatal error: Maximum execution time of 30 seconds exceeded wp-db.php on line 70

    Thanks in advance

  17. @Stephen: No that’s not a problem, that’s a feature. I am considering that as well when working on the next versions.

    @infonote: The max execution time problem is faced by many with slow connection (server « – » blogger), but some even managed to get 900 post at one go (earlier versions). Try lowering the number of posts per stage to a comfortable level. Staging is introduced just because of that. Seek the previous comments for comments from users with same issue…

Comments are closed.