Migrate Google Notebook notes to personal database using PHPPosted by Matt Thommes on May 14, 2009 | Post type: Gain Ever since Google Notebook closed it's doors on any future development and support, I've had this thought that it might be wise to use another web notebook utility for saving text snippets through a browser. Existing Google Notebook users can still use the application, but without any new development and support, it kind of feels like a wedding without the bride and groom. Since I am a web developer, I've decided the best route is a custom-built application, rather than spending time learning another web notebook application, and possibly having to pay for it. This post is just a brief mention of how simple it is to copy existing Google Notebook notes to a personal database. It is not, by any means, a complete tutorial. The processThe first thing I need to do is migrate Google Notebook notes into my own MySQL database. I've created a bare-bones database table to start - at least enough fields to migrate my existing notes from Google Notebook into the table:
The Next, I'll get an export of an individual notebook from Google Notebook:
The Atom option will work just fine for our needs. This will prompt you to download the XML file:
With PHP, I'm going to loop through each note and insert into my database. First, upload the XML file to your web server where PHP is running. You might want to give it a URL-friendly filename while you're at it. I've renamed my exported notebook file to:
Next, in your PHP script, your code to insert each note into your own database could look something like this:
$my_notebook_xml = curl("http://paininthetech.com/my_notebook.xml");
foreach ($my_notebook_xml -> entry as $item)
{
$query = "INSERT INTO notebook_item (item, modify_date) VALUES ('" . str_replace("'", "\'", $item -> content) . "', '" . date("Y-m-d H:i:s", strtotime($item -> updated)) . "')";
$sql = &$dbConn -> query($query);
}
Here we use cURL to grab the XML content, then loop through it using a
In my tests, I was able to quickly copy over 400 notes from Google Notebook's XML export into my personal database, in seconds. Larger notebooks will obviously take longer. Overall, this shows you how simple it can be to migrate old Google Notebook notes into your own database with PHP. About the author(s)Matt Thommes is an independent publishing enthusiast, mobile blogger, content creator, informative writer, web developer from a suburb of Chicago. Never one to conform, Matt intends to promote the effect the web has on our lives, in an effort to intensify, instruct, and clarify all that is happening around us. Comments
|
Quick Link to this postTTIP.me/2180 |