APIFinder
   The essential directory of application programming interfaces
Submit an API
DevX
Function
Language/OS
Contribute
About
Browse DevX
advertisement
Log In | Register
Using Google's Data API in Brew: An Introduction
Add functionality to your Brew applications with IWEB and Google's powerful Calendar API. 
April 22, 2008

advertisement
Recently, Google released its robust "Google Data API" with little fanfare. In fact, if you aren't an avid tech blog reader or didn't go to Google Developer Day, you might have missed it. Upon inspection, it's clear that Google did not have the mobile developer in mind when mapping out these APIs, but that doesn't mean you can't make the most of the tools they've released. While Google has made pre-compiled libraries available for several higher order languages (from Java to Python), as Brew developers, you will have to take the hard road and use HTTP. However, since the HTTP protocol API is the least common denominator, it will work well on any system with a decent HTTP/HTTPS implementation.

In this article, you'll learn to add basic Calendar functionality to your mobile application and how to get the XML feed for a public calendar and login through secure HTTPS. Along the way, you should get a good sense of how to use IWEB and Brew's straightforward implementation of SSL. This article is meant as an introduction to Google's API, not a tour de force. Stay tuned to this site as forthcoming articles will deal with J2ME development and more complicated features.

Carefully Consider Your Options
Before diving into writing some Brew code, you have a very important decision to make. Integrating your Brew application directly with Google's web service can have some dangerous consequences. This issue is a classic conundrum in the mobile world. Do you integrate directly with a third party's servers or do you write a server layer to bridge your Brew application and the third party service? It's important to point out a few things to consider before coming to a final decision. First, if Google "updates" its API without support for backwards compatibility, your application will fail to interact with the service. This could have the nasty side effect of forcing you to resubmit your application to NSTL. Second, Google could remove the service entirely, forcing you to remove your app from the catalogue or disable portions of it. Recently Google removed its SOAP search API, much to the chagrin of the developers who made use of it. Fair warning: just because it's working now doesn't guarantee that it will continue working in the future.

The alternative has its drawbacks as well. Developing a server layer adds to your costs—which can be far more expensive than a round of NSTL submits. Additionally, you'll have to pay for the bandwidth and CPU time for your server middleware. At the least, I'd suggest sending the traffic through a simple proxy you control, so at some later date you could modify your server to follow the changes in Google's API.

You've probably had enough warnings and doom and gloom; let's look at some code.

Retrieving a Public Feed
The first, and possibly simplest, way you'll interact with the Google calendar API is to retrieve an XML feed for a public calendar. It's a great place to start because it involves one (sometimes two) simple HTTP get requests and no cookies or tokens. First, make sure the calendar you want to access is public. Once that's done, you should be able to access it through this simple function:


static void GetCalendarStream(void *pData)
{
GApp *pme = (GApp*)pData;
char *szPostHeader;
ISourceUtil *pUtil;
IPeek *ppeek;
ISHELL_CreateInstance(pme->a.m_pIShell,
AEECLSID_WEB, (void **)&pme->pEventWeb);
CALLBACK_Init(&pme->clb, CalCallback, pme);
szPostHeader = MALLOC(200);
SPRINTF(szPostHeader, "Content-Type:application/atom+xml\r\n");
IWEB_GetResponse(pme->pEventWeb,(pme->pEventWeb,
&pme->pResp, &pme->clb,
"http://www.google.com/calendar/feeds/joe@gmail.com/public/full",
WEBOPT_HEADER, szPostHeader,
WEBOPT_METHOD, "GET",
WEBOPT_HANDLERDATA, pme,
WEBOPT_HEADERHANDLER, EventHeader,
WEBOPT_COPYOPTS, TRUE,
WEBOPT_END));
FREE(szPostHeader);
}
This is a fairly straightforward example of an IWEB GetResponse call. You'll need to set the content type in the headers by hand. Google specs out the feed URL as follows:

"http://www.google.com/calendar/feeds/*email-address*/*access-level*/*feed-level*"
In the previous example, you can see that you've looked up a non-existent joe@gmail.com account. This example requests only public events (hence the "public" access level) and full details on all those events. To read calendars that have not been made public, you'll have to log in. You'll see more on that later.

Now that you've requested all this data, how do you receive it?

Continue reading the article on DevX.com...

Chris Haseman is an independent software engineer specializing in wireless development. He can be found riding his bike between coffee shops in San Francisco. In his spare time, he's a resident DJ at xtcradio.com and a martial arts instructor.


Google Data APIs
The Google data APIs ("GData" for short) provide a simple standard protocol for reading and writing data on the web. GData uses either of two standard XML-based syndication formats: Atom or RSS. It also has a feed-publishing system that consists of the Atom publishing protocol plus some extensions (using Atom's standard extension model) for handling queries.
Provider: Google   Cost: 0




JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Microsoft Article: 7.0, Microsoft's Lucky Version?
Microsoft Article: Hyper-V--The Killer Feature in Windows Server 2008
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Windows Server 2008
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES