954,576 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Hoping for newbe help with this Zend script (Google API)

Hi folks,
I am still quite new here, and brand new to Zend and PHP, so please forgive my ignorance...I'm sadly still very much a paint by numbers hack. :-D

I'm wanting to do what I think is a fairly simple task:

Collect info from one of my google calendars via the API and display that info in a table on a page on my website.

I have succesfully installed Zend and I have used this code to access my google calendar:

<?php
// load library
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
Zend_Loader::loadClass('Zend_Http_Client');

// create authenticated HTTP client for Calendar service
$gcal = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
$user = "EMAIL@GMAIL.COM";
$pass = "XXXXXXXXX";
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $gcal);
$gcal = new Zend_Gdata_Calendar($client);

// generate query to get event list
$query = $gcal->newEventQuery();
$query->setUser('default');
$query->setVisibility('private');
$query->setProjection('basic');

// get and parse calendar feed
// print output
try {
$feed = $gcal->getCalendarEventFeed($query);
} catch (Zend_Gdata_App_Exception $e) {
echo "Error: " . $e->getResponse();
}
?>
<h1><?php echo $feed->title; ?></h1>
<?php echo $feed->totalResults; ?> event(s) found.
<p/>
<ol>

<?php
foreach ($feed as $event) {
echo "<li>\n";
echo "<h2>" . stripslashes($event->title) . "</h2>\n";
echo stripslashes($event->summary) . " <br/>\n";
echo "</li>\n";
}
echo "</ul>";
?>

This gives me my default calendar information, but:
1) I want to be able to choose which calendar to display.
2) I want to be able to display the information in different columns, etc

Anyone able to point me in the right direction?

Thanks for your time!
Joel

mbirame
Light Poster
34 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

Change $query = $gcal->newEventQuery()
to
$query = $gcal->newEventQuery( $FEEDURL)

where $FEEDURL is the private link from GCal.

CDTOAD
Newbie Poster
1 post since Oct 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You