2012-05-14 38 views
0

我一直在嘗試在CakePHP中使用ZEND GData API,並讓它設置並檢索日曆列表。Zend Gdata日曆錯誤請求錯誤

所有這些工作,但是當我嘗試檢索日曆事件時,我得到一個錯誤的請求錯誤,我不知道如何解決它。這是運行腳本時接收到的錯誤消息的代碼。

* 注:我測試這個從我的機器使用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++; 
     } 

以下是錯誤消息:

Error: HTTP/1.1 400 Bad Request Content-type: text/html; charset=UTF-8 Date: Mon, 14 May 2012 04:04:41 GMT Expires: Mon, 14 May 2012 04:04:41 GMT Cache-control: private, max-age=0 X-content-type-options: nosniff X-frame-options: SAMEORIGIN X-xss-protection: 1; mode=block Server: GSE Connection: close Invalid request URI

感謝您的時間和幫助。

回答

3
  1. $service->newEventQuery()這裏不需要參數。

  2. 我相信你是從一個用戶檢索日曆列表。我們說這是你自己。所以

    $query->setUser('default');

    不會幫助你得到任何第二個日曆,而不是隻在主日曆這名字是你的電子郵件地址。

    Google developer protocol guide

    請參見獲取飼料,您發送以下HTTP請求到日曆,使用你這個文檔的一節中找到的網址:

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

    所以替換userid用您的calendarID獲取特定日曆的事件Feed。

嘗試

$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++; 
    }