0

我正在按照http://www.ibm.com/developerworks/library/x-googleclndr/上的教程使用 Google 日历 API,但遇到了一些奇怪的问题。我的 PHP 代码看起来像这样

    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 = "daniel.lieberman610@gmail.com";
    $pass = "*******";
    $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($user);
    $query->setVisibility('private');
    $query->setProjection('basic');

    //get and parse calendar feed
    //print output

    try {
        $feed = $gcal->getCalendarEventFeed($query);
        echo "<!--comment-->\n";
    } catch (Exception $e) {
        echo "<!--different comment-->\n";
    }

try 块内发生了某种异常,但不是Zend_Gdata_App_Exception因为没有显示错误消息。我无法弄清楚我做错了什么。

另外,我在这里学习PHP。非常感谢你的帮助。

4

1 回答 1

0

将 try 代码移动到文件的开头。是否显示错误?在这里,您将找到一个我在 Joomla 扩展程序中使用的工作示例https://github.com/Digital-Peak/GCalendar/blob/master/com_gcalendar/admin/libraries/GCalendar/GCalendarZendHelper.php

顺便说一句,我建议迁移到新的谷歌日历 API v3,因为他们可能会在明年关闭版本 2(使用 Zend)。这是库的链接https://developers.google.com/google-apps/calendar/downloads

于 2013-06-24T11:38:00.500 回答