So I'm trying to connect to Google Calendar via the Data API and I'm
authenticating with ClientLogin.
When I implement my code without putting into a class structure, it works,
but when I try to piece it out into a class... not so much. :( I've even
tried including the class on the same page/in the same file and it still
doesn't work. All I'm trying to do is just list out the calendars available
and their ID's right now.
Any help/thoughts/ideas on this would be greatly appreciated. :D
*The error I'm getting is: *
HTTP Exception Error: Expected response code 200, got 401
Authorization required
Error 401
*Here's my class that I have so far:*
require_once('Zend/Loader.php');
$classes = array('Zend_Gdata', 'Zend_Gdata_Query', 'Zend_Gdata_ClientLogin',
'Zend_Gdata_Calendar');
foreach ($classes as $class) {
Zend_Loader::loadClass($class);
}
class GoogleCal {
static $gcal = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
private $email;
private $password;
private $calendar; //setUser()
private $client;
private $gdataCal;
private $visibility;
private $projection;
function __construct($gmail, $password, $calendar) {
$this->email = $gmail;
$this->password = $password;
$this->calendar = $calendar;
try {
$this->client = Zend_Gdata_ClientLogin::getHttpClient($gmail, $password,
$this->gcal);
} catch (Zend_Gdata_App_CaptchaRequiredException $cre) {
//need to add in AJAX here to make this seamless. :)
//need to make sure that the getHttpClient() call includes this extra stuff:
/*
http://framework.zend.com/manual/en/zend.gdata.clientlogin.html
*/
echo "<img src=\"" . $cre->getCaptchaUrl() . "\" /><br/>" .
"<form name=\"google_captcha\"><input type=\"hidden\" id=\"captcha_token\"
value=\"" . $cre->getCaptchaToken() . "\">" .
"<input type=\"text\" id=\"captcha_response\">";
} catch (Zend_Gdata_App_AuthException $ae) {
echo "Problem authenticating: " . $ae->exception() . "\n\n";
}
//echo "headers: " . $this->client->Zend_Http_Client::getHeaders() .
"<br/>";
$this->gdataCal = new Zend_Gdata_Calendar($this->client);
}
function getCalendarListFeed()
{
try {
$listFeed = $this->gdataCal->getCalendarListFeed();
} catch (Zend_Gdata_App_HttpException $he) {
echo "HTTP Exception Error: " . $he->getMessage();
} catch (Zend_Gdata_App_Exception $e) {
echo "Generic Error: " . $e->getMessage();
}
return $listFeed;
}
} //end class
--
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