This script exports your posts and categories from your locally hosted WordPress blog and imports them into a new Blogger blog online. The script is based on the Blogger examples for working with PHP and blog data.
You need to have the Zend Framework up and running on your system as it contains all the GData libraries for working with Google data in PHP. This script doesn’t use any of the MVC, so you just need to have the files somewhere that you can require them.
You need to edit line 8 to point to the path of your Zend Framework. You also need to update the database connection variables right below that to match your wordpress blog.
- Blogger can only import 50 blog posts per day before tripping some anti-spam protection. So the SQL “limit” clause around line 322 will need to be adjusted. It is set to get the first 50 posts and publish them.
- WordPress “categories” become Blogger “labels”
- Blogger forces any imported comments to the blog posts to originate from you, the author, of the blog. So I have omitted these from my script, figuring it would look crazy to be talking to myself. You could hack this script to add those back in.
What’s great about Blogger is that you can create a new test blog and run this script, which allows you to select which Blogger blog you wish to update and go from there.
The usage is:
php xfer_to_blogger.php –email@example.com –pass=password
The email and password here are the ones you used in setting up your Blogger account. Let me know how you make out and if you have any suggestions for the code.