If you have successfully obtained a calendar feed, you should receive some XML looking like this
-
<default:feed>
-
<default:id>http://www.google.com/calendar/feeds/vinoajtest%40gmail.com/public/basic</default:id>
-
<default:updated>2007-04-08T03:38:29.000Z</default:updated>
-
<default:category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/>
-
<default:title type="text">Vinoaj Vijeyakumaar</default:title>
-
<default:subtitle type="text">Vinoaj Vijeyakumaar</default:subtitle>
-
<default:link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://www.google.com/calendar/feeds/vinoajtest%40gmail.com/public/basic"/>
-
<default:link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/vinoajtest%40gmail.com/public/basic?max-results=25"/>
-
<default:author>
-
<default:name>Vinoaj Vijeyakumaar</default:name>
-
<default:email>vinoajtest@gmail.com</default:email>
-
</default:author>
-
<default:generator version="1.0" uri="http://www.google.com/calendar">Google Calendar</default:generator>
-
<openSearch:totalResults>1</openSearch:totalResults>
-
<openSearch:startIndex>1</openSearch:startIndex>
-
<openSearch:itemsPerPage>25</openSearch:itemsPerPage>
-
<gCal:timezone value="Australia/Sydney"/>
-
<default:entry>
-
<default:id>
-
http://www.google.com/calendar/feeds/vinoajtest%40gmail.com/public/basic/12ps2qhasoejgtf8uo89des4f0
-
</default:id>
-
<default:published>2007-04-08T03:35:52.000Z</default:published>
-
<default:updated>2007-04-08T03:36:23.000Z</default:updated>
-
<default:category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/>
-
<default:summary type="html">When: Mon Apr 9, 2007<br></default:summary>
-
<default:link rel="alternate" type="text/html" href="http://www.google.com/calendar/event?eid=MTJwczJxaGFzb2VqZ3RmOHVvODlkZXM0ZjAgdmlub2FqdGVzdEBt" title="alternate"/>
-
<default:link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/vinoajtest%40gmail.com/public/basic/12ps2qhasoejgtf8uo89des4f0"/>
-
</default:entry>
-
</default:feed>
A fully-formed private event looks something like this
-
<entry>
-
<id>http://www.google.com/calendar/feeds/vinoajtest%40gmail.com/private/full/12ps2qhasoejgtf8uo89des4f0</id>
-
<published>2007-04-08T03:35:52.000Z</published>
-
<updated>2007-04-08T03:36:23.000Z</updated>
-
<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/g/2005#event"/>
-
<title type="text">Easter Monday</title>
-
<content type="text"/>
-
<link rel="alternate" type="text/html" href="http://www.google.com/calendar/event?eid=MTJwczJxaGFzb2VqZ3RmOHVvODlkZXM0ZjAgdmlub2FqdGVzdEBt" title="alternate"/>
-
<link rel="self" type="application/atom+xml" href="http://www.google.com/calendar/feeds/vinoajtest%40gmail.com/private/full/12ps2qhasoejgtf8uo89des4f0"/>
-
<author>
-
<name>Vinoaj Vijeyakumaar</name>
-
<email>vinoajtest@gmail.com</email>
-
</author>
-
<gd:visibility value="http://schemas.google.com/g/2005#event.public"/>
-
<gCal:sendEventNotifications value="false"/>
-
<gd:transparency value="http://schemas.google.com/g/2005#event.transparent"/>
-
<gd:comments>
-
<gd:feedLink href="http://www.google.com/calendar/feeds/vinoajtest%40gmail.com/private/full/12ps2qhasoejgtf8uo89des4f0/comments"/>
-
</gd:comments>
-
<gd:eventStatus value="http://schemas.google.com/g/2005#event.confirmed"/>
-
<gd:where/>
-
<gd:when startTime="2007-04-09" endTime="2007-04-10">
-
<gd:reminder minutes="10"/>
-
</gd:when>
-
</entry>
The following steps show you how to grab a feed using Zend Framework's GData package and then grab the appropriate values.
-
//Initiate an authorised http client
-
//See previous post on how to get an auth token and convert it to a session token
-
$client = Zend_Gdata_AuthSub::getHttpClient($authToken);
-
-
//Instantiate a new GData Calendar instance + set the identifiers and parameters
-
$gdata_cal = new Zend_Gdata_Calendar($client);
-
$gdata_cal->setUser('vinoajtest@gmail.com');
-
$gdata_cal->setVisibility('private');
-
$gdata_cal->setProjection('full');
-
-
//Returns an atom feed object represented by Zend_Feed_Atom
-
//The Zend_Feed_Atom object is an extension of DOMDocument
-
//Call Zend_Feed_Atom::saveXML() to acquire a fully-formed DOMDocument at any time
-
$gdata_cal_feed = $gdata_cal->getCalendarFeed();
-
-
//Let's spit out some basic FEED information
-
$n_entries = $gdata_cal_feed->count(); //int
-
$feed_title = $gdata_cal_feed->title(); //str
-
$feed_id = $gdata_cal_feed->id(); //str url
-
-
$feed_links = $gdata_cal_feed->link(); //array links
-
foreach ($feed_links as $ix => $link){
-
//Each item is of type DOMElement
-
$link_rel = $link->getAttribute('rel');
-
$link_type = $link->getAttribute('type');
-
$link_href = $link->getAttribute('href');
-
}
-
-
$feed_subtitle = $gdata_cal_feed->subtitle(); //Equivalent to a RSS' channel description
-
$feed_author_name = $gdata_cal_feed->author->name(); //str
-
$feed_author_email = $gdata_cal_feed->author->email(); //str email
-
-
//Now lets's spit out ENTRIES and their information
-
foreach ($gdata_cal_feed as $ix => $cal_entry){
-
$cal_entry_id = $cal_entry->id(); //str url
-
$cal_entry_title = $cal_entry->title(); //str
-
$cal_entry_author = $cal_entry->author->name(); //str
-
$cal_entry_content = $cal_entry->content(); //str
-
$cal_entry_email = $cal_entry->author->email(); //str email
-
$cal_entry_published = $cal_entry->published(); //str date
-
$cal_entry_updated = $cal_entry->updated(); //str date
-
$cal_entry_summary = $cal_entry->summary(); //str
-
$cal_entry_visibility = $cal_entry->{'gd:visibility'}['value']; //str bool
-
$cal_entry_sendeventnotify = $cal_entry->{'gCal:sendEventNotifications'}['value'];
-
$cal_entry_transparency = $cal_entry->{'gd:transparency'}['value']; //str
-
$cal_entry_event_status = $cal_entry->{'gd:eventStatus'}['value']; //str
-
$cal_entry_where = $cal_entry->{'gd:where'}['valueString']; //str
-
$cal_entry_starttime = $cal_entry->{'gd:when'}['startTime']; //str date
-
$cal_entry_endtime = $cal_entry->{'gd:when'}['endTime']; //str date
-
$cal_entry_reminder_mins = $cal_entry->{'gd:when'}->{'gd:reminder'}['minutes']; //str mins
-
$cal_entry_commentsfeedlink = $cal_entry->{'gd:comments'}->{'gd:feedLink'}['href']; //str url
-
-
$cal_entry_links = $cal_entry->link();
-
foreach ($cal_entry_links as $ix => $entry_link){
-
$entry_link_rel = $entry_link->getAttribute('rel'); //str
-
$entry_link_type = $entry_link->getAttribute('type'); //str
-
$entry_link_href = $entry_link->getAttribute('href'); //str url
-
$entry_link_title = $entry_link->getAttribute('title'); //str
-
}
-
-
//category
-
$cal_entry_category = $cal_entry->{'category'}; //Type Zend_Feed_Entry
-
$cal_entry_category_dom = $cal_entry_category->getDOM(); //Convert it to a DOM element so we can read off the attributes
-
$cal_entry_category_scheme = $cal_entry_category_dom->getAttribute('scheme');
-
$cal_entry_category_term = $cal_entry_category_dom->getAttribute('term');
-
}
