我想在一個時間戳(比方說一個小時前)之後獲取在Google日曆上創建的所有事件。
我正在使用Zend GData庫。Zend GData日曆:我不能在查詢中使用setUpdatedMin
如果我運行該代碼(初始化需要之後)一切完美:
$query = $this->service->newEventQuery();
$query->setUser($this->getCalendarId());
$query->setVisibility('private');
$query->setProjection('full');
$query->setOrderby('starttime');
$query->setSingleevents('false');
$query->setParam('ctz', 'UTC');
$query->setMaxResults(5000);
// Retrieve the event list from the calendar server
try {
$eventFeed = $this->service->getCalendarEventFeed($query);
} catch (Zend_Gdata_App_Exception $e) {
echo "Error: " . $e->getMessage();
}
但是當我嘗試設置查詢的更新分鐘參數以這種方式:
$dateFormat = 'Y-m-d\TH:i:s\Z';
$query->setUpdatedMin(date($dateFormat, time()-3600));
我得到這個錯誤:
Unknown authorization header
Error 401
然後,我發現了一些很有趣的調試在Zend的GData庫: 是被被紅牌罰下谷歌的網址是:
http://www.google.com:80/calendar/feeds/[email protected]om/private/full?orderby=starttime&singleevents=false&ctz=UTC&max-results=5000&updated-min=2011-03-14T15:17:37Z
如果我把它變成這樣(我只有改變的http://到https://)
https://www.google.com/calendar/feeds/[email protected]om/private/full?orderby=starttime&singleevents=false&ctz=UTC&max-results=5000&updated-min=2011-03-14T15:17:37Z
並在谷歌瀏覽器中粘貼該URL我得到了2011-03-14T15:17:37Z之後更新的所有事件,如我所願。
此基礎上,我認爲這將是一個好主意,改變初始化代碼$範圍變量的內容來生成用於用戶認證的網址:從
$scope = "http://www.google.com/calendar/feeds";
$next = getCurrentUrl();
$scope = "http://www.google.com/calendar/feeds";
$secure = true;
$session = true;
// Redirect the user to the AuthSub server to sign in
$authSubUrl = Zend_Gdata_AuthSub::getAuthSubTokenUri($next,
$scope,
$secure,
$session);
到
$scope = "https://www.google.com/calendar/feeds/";
(如這裏記錄http://code.google.com/apis/calendar/data/1.0/developers_guide_php.html)
但在這種情況下,我得到:
Token invalid - AuthSub token has wrong scope
我有10個的調試時間和谷歌上搜索後江郎才盡了!我不知道該怎麼辦。 請任何想法或解決方法是非常受歡迎的。
感謝,
丹