Zend Gdata 日历错误请求错误


Zend Gdata Calendar Bad Request Error

我一直在尝试在CakePHP中使用ZEND GData API,并对其进行设置并检索日历列表。

所有这些都有效,但是当我尝试检索日历事件时,我收到一个错误的请求错误,我不确定如何解决它。下面是运行脚本时收到的错误消息后跟的代码。

*注意:我正在使用XAMPP从我的机器上对此进行测试

        //GET LIST OF EVENTS
        $index = 0;
        foreach($listFeed as $list) {
            $query = $service->newEventQuery($list->link[0]->href);
            // Set different query parameters
            $query->setUser('default');
            $query->setVisibility('private');
            $query->setProjection('full');
            $query->setOrderby('starttime');
            // Get the event list
            try {
                $eventFeed[$index] = $service->getCalendarEventFeed($query);
            } catch (Zend_Gdata_App_Exception $e) {
                echo "Error: " . $e->getResponse() . "<br />";
            }
            $index++;
        }

以下是错误消息:

错误:

HTTP/1.1 400 错误请求 内容类型:文本/html; 字符集=UTF-8 日期:2012 年 5 月 14 日星期一 04:04:41 GMT 到期: 周一, 14 五月 2012 04:04:41 GMT 缓存控制:私有,最大年龄=0 X 内容类型选项:嗅探 X帧选项:同源 X-xss-保护:1; 模式=块 服务器:GSE 连接:关闭 无效的请求 URI

感谢您的时间和帮助。

  1. $service->newEventQuery()这里不需要参数。

  2. 我相信您正在从单个用户检索日历列表。假设是你自己。所以

    $query->setUser('default');

    不会帮助您获取任何第二个日历,而只会获取名称为您的电子邮件地址的主日历。

    参考谷歌开发者协议指南

    要获取源,请使用在本文档上一节中找到的 URL 向日历发送以下 HTTP 请求:

    GET https://www.google.com/calendar/feeds/userID/private-magicCookie/full

    因此,请将用户 ID 替换为您的日历 ID 以获取特定日历的事件源。

尝试

    $index = 0;
    foreach($listFeed as $list) {
        $calendarID = $list->id->text;
        $user = str_replace("http://www.google.com/calendar/feeds/default/owncalendars/full/", '', $calendarID);
        $query = $service->newEventQuery();
        // Set different query parameters
        $query->setUser($user);
        $query->setVisibility('private');
        $query->setProjection('full');
        $query->setOrderby('starttime');
        // Get the event list
        try {
            $eventFeed[$index] = $service->getCalendarEventFeed($query);
        } catch (Zend_Gdata_App_Exception $e) {
            echo "Error: " . $e->getResponse() . "<br />";
        }
        $index++;
    }