edoceo: Latin "to inform fully, instruct thoroughly"

../webpage/int-main/20070605-google-clientlogin-api.phtml


Google provides an API for applications to get authentication tokens and use them to request services. This allows one to tie Google applications into their own system or web applications.

One API is designed for stand alone applications and another is for web applications. Below is an example of using the ClientLogin API from a web application so as to embed Google Calendar with an iframe. Our Imperium product used to contain it's own calendar code, now we just embed Google's.

ClientLogin Request

Generate the URL to be used

$buf = sprintf('accountType=HOSTED&Email=%s&Passwd=%s&service=cl&source=%s',
  rawurlencode($username),
  rawurlencode($password),
  rawurlencode($codename)

Send it to Google, maybe tune the curl options.

$ch=curl_init('https://www.google.com/accounts/ClientLogin');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $buf);
$res = curl_exec($ch);

Read the Response

preg_match('/auth=(.+)/i',$res,$m);
$authcode = $m[1];

Now using that authcode we can use and iframe to embed a Google Calendar into our application as follows.

$url = 'http://www.google.com/calendar/hosted/edoceo.com/render?auth='.$authcode;
echo "<iframe id='google_calendar' src='$url'></iframe>\n";

This same functionality can be used to auto-login for Google Mail and other applications too. It's simply a matter of changing the URL to that of the Google Application to connect to.

Google Apps: http://partnerpage.google.com/edoceo.com?auth=DQAAAHoAAAAM7j_mxeblE2FCh26EhFTe7m_oKAGxZLeddsXT_DQB-xTPhv-0d3bTZ5Qu0M-CO9OVjpN5-IlvmxvVnBfY3JMZRyZktmoVgP5EDT3bh1RGa30guaFdCTfyl72im-zQYf8ovRO7WxPU_OGJEG_PKmtWR0TbxcFoFVewTXlTZvIIUQ Google Mail http://mail.google.com/a/edoceo.com/?auth=

XHTML 1.1. and CSS2.1/3 © 1999-2008 Edoceo, Inc.
Edit this Page