So, what this code does is, it gets google calendar events using cURL. The code is simple. Just the retrieving of xml feed of google calendar events is done here, after this we can parse the xml and display all the events to our custom page after some formatting. Checkout the code.
$fAuth = "authentication-token-obtained-after-successful-login";
$arr_headers = array();
$arr_headers[] = "Host: www.google.com";
$arr_headers[] = "MIME-Version: 1.0";
$arr_headers[] = "Accept: text/xml";
$arr_headers[] = "Authorization: GoogleLogin auth=".$fAuth;
$arr_headers[] = "Content-type: application/atom+xml";
$arr_headers[] = "Cache-Control: no-cache";
$arr_headers[] = "Connection: Keep Alive \r\n";
$url = "http://www.google.com/calendar/feeds/emialadd%40gmail.com/private/full";
$ch = curl_init();
curl_setopt($ch, CURLOPT_REFERER, "http://google.com");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $arr_headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4b) Gecko/20040612 Mozilla Firebird/0.9");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$resFin = curl_exec($ch);
echo $resFin;
?>
2 comments:
Hi
Am using oAuth2.0 with php. may i know how we can retrieve the same calendar event feeds using oauth2.0 instead of google login which you have used here with curl. Please let me know.
Thanks
Krishna
Pls let me know
Post a Comment