H Alain

yes, sorry been a touch busy.

the below code should give you your calendar data via oauth.

All the best

Garry

<?php

/**
 * Access calendar data via OAuth
 */

set_include_path(get_include_path() . PATH_SEPARATOR . "/PATH/TO/
ZendFramework-1.11.10/library");

require_once '/PATH/TO/YOUR_SECRETS.php';
require_once 'Zend/Loader.php';
require_once 'Zend/Oauth.php';
require_once 'Zend/Oauth/Consumer.php';
require_once 'Zend/Gdata/Calendar.php';
require_once 'Zend/Gdata/Calendar/EventQuery.php';
require_once 'Zend/Gdata/Calendar/EventEntry.php';

# NB small hack to Zend/Gdata/Calendar.php required, as per...
# 
http://www.google.com/support/forum/p/apps-apis/thread?tid=5dd3043700c5986d&hl=en

/**
 * Setup OAuth
 */
$options = array(
    'requestScheme' => Zend_Oauth::REQUEST_SCHEME_HEADER,
    'version' => '1.0',
    'signatureMethod' => 'HMAC-SHA1',
    'consumerKey' => $CONSUMER_KEY,
    'consumerSecret' => $CONSUMER_SECRET,
);

/**
 * Create HTTP Client object which adds OAuth Authorization
 * headers to outbound requests.
 */
$consumer = new Zend_Oauth_Consumer($options);
$token = new Zend_Oauth_Token_Access();
$httpClient = $token->getHttpClient($options);

$gdataCal = new Zend_Gdata_Calendar($httpClient);

$gdataCal->xoauth_requestor_id = "username%40domain";

$calFeed = $gdataCal->getCalendarListFeed();

echo "<h1>" . $calFeed->title->text . "</h1>\n";

echo "<ul>\n";
foreach ($calFeed as $calendar) {
                echo "<li>" . $calendar->title->text . " // " . $calendar->id-
>text . "</li>\n";

                /**
                 * This is the bit I couldn't get to work by building a query 
string
as per the api docs
                 • e.g. 
http://code.google.com/apis/calendar/data/1.0/developers_guide_php.html#RetrievingWithoutQuery
                 */
                $eventFeed = $gdataCal->getCalendarEventFeed($calendar->content-
>src);
                  echo "<ul>\n";
                  foreach ($eventFeed as $event) {
                    echo "\t<li>" . $event->title->text .  " (" . 
$event->id->text .
")\n";
                    echo "\t\t<ul>\n";
                    foreach ($event->when as $when) {
                      echo "\t\t\t<li>Starts: " . $when->startTime . "</li>\n";
                    }
                    echo "\t\t</ul>\n";
                    echo "\t</li>\n";
                  }


}
echo "</ul>\n";


?>

-- 
You received this message because you are subscribed to the Google
Groups "Google Calendar Data API" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://code.google.com/apis/calendar/community/forum.html

Reply via email to