从带有魔术cookie的Feed中获取Google日历

时间:2012-03-05 11:48:58

标签: php zend-framework

我正在尝试从Google日历中获取Feed。它在设置中设置为公开,我真的相信我收到了电子邮件和私人cookie。

<html>
<head>
  <title>test</title>
</head>
<body>

  <?php
    set_include_path(get_include_path().PATH_SEPARATOR.'/usr/share/php/libzend-framework-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');

    $gdataCal = new Zend_Gdata_Calendar();
    $query = $gdataCal->newEventQuery();
    $query->setUser('xxxxxx@gmail.com');
    $query->setVisibility('private-xxxxxxxxxxetc');
    $query->setProjection('full');
    $eventFeed = $gdataCal->getCalendarEventFeed($query);
    foreach ($eventFeed as $event) {
      echo $event->title->text . '<br />';
    }

  ?>
</body>
</html>

但是我得到了这样的400错误:

Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 400
Incorrect private url.' in /usr/share/php/libzend-framework-php/Zend/Gdata/App.php:709
Stack trace:
#0 /usr/share/php/libzend-framework-php/Zend/Gdata.php(221): Zend_Gdata_App->performHttpRequest('GET', 'https://www.goo...', Array, NULL, NULL, NULL)
#1 /usr/share/php/libzend-framework-php/Zend/Gdata/App.php(875): Zend_Gdata->performHttpRequest('GET', 'https://www.goo...', Array)
#2 /usr/share/php/libzend-framework-php/Zend/Gdata/App.php(763): Zend_Gdata_App->get('https://www.goo...', NULL)
#3 /usr/share/php/libzend-framework-php/Zend/Gdata/App.php(205): Zend_Gdata_App->importUrl('https://www.goo...', 'Zend_Gdata_Cale...', NULL)
#4 /usr/share/php/libzend-framework-php/Zend/Gdata.php(162): Zend_Gdata_App->getFeed('https://www.goo...', 'Zend_Gdata_Cale...')
#5 /usr/share/php/libzend-framework-php/Zend/Gdata/Calendar.php(107): Zend_Gdata->getFeed('https://www.goo...', 'Zend_Gdata_Cale...')
#6 /var/www/gcal/index.ph in /usr/share/php/libzend-framework-php/Zend/Gdata/App.php on line 709

可能出现什么问题?

私有xml Feed网址以“/ basic”结尾,因此我尝试将$query->setProjection('full');更改为$query->setProjection('basic');但是这样做无效。

1 个答案:

答案 0 :(得分:0)

变化

$query->setUser('xxxxxx@gmail.com');

到:

$query->setUser('default');

或者,如果您想从第二个日历中获取活动。检查这个问题:

Zend Gdata Calendar Bad Request Error