Use Google Bookmarks in your C# WinForms application
Google has a number of services available which I aim to make API's for that nothing exists for currently. The first of those being Google Bookmarks. After lots of hours spent intercepting HTTP requests I have finally created a control capable of retrieving all bookmarks for a given account. In its current version this control only has the ability to retrieve the bookmarks. It cannot create or modify yet, but this will come with a future version. To date I have not found a single piece of code outside of FireFox extensions for utilizing the Google Bookmarks service. I hope you find this of use.
The least you need to know
There are only 4 steps to implementing this control.
- Add the
tbsGoogleBookmarksclass to your project. - Declare an instance of the class
- Define a function to handle the
BookmarksRefreshedevent - Initialize the class with the username and password
Declare an instance
//Because we will assign an event handler to this you
//will want to declare it globally
tbsGoogleBookmarks gBookmarks = new tbsGoogleBookmarks();Define an event handler in the Form Load event
private void Form1_Load(object sender, EventArgs e)
{
gBookmarks.BookmarksRefreshed += new RefreshedEventHandler(gBookmarks_BookmarksRefreshed);
}
Handle the event
private void gBookmarks_BookmarksRefreshed(string username)
{
listView1.Items.Clear();
for (int bIndex = 0; bIndex <>
{
ListViewItem iBookmark = new ListViewItem();
iBookmark.Text = gBookmarks.Bookmark(bIndex).Title;
iBookmark.SubItems.Add(gBookmarks.Bookmark(bIndex).URL);
iBookmark.SubItems.Add(gBookmarks.Bookmark(bIndex).Category);
listView1.Items.Add(iBookmark);
}
}
Now we just need to initialize the class and sit back and let it all happen.
gBookmarks.Init("UserName", "Password");
When the bookmarks have been retrieved, the BookmarksRefreshed event is fired and your list is updated. This can easily be applied to a Tool Strip or other similar control to build a menu.
To download the project source or sample application, view the article on CodeProject.