タイムスタンプの後に Google カレンダーで作成されたすべてのイベントを取得しようとしています (1 時間前としましょう)。
Zend GData ライブラリを使用しています。
このコードを (初期化が必要な後に) 実行すると、すべてが完全に機能します。
$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();
}
しかし、この方法でクエリの updated-min パラメータを設定しようとすると:
$dateFormat = 'Y-m-d\TH:i:s\Z';
$query->setUpdatedMin(date($dateFormat, time()-3600));
次のエラーが表示されます。
Unknown authorization header
Error 401
その後、Zend Gdata ライブラリのデバッグで非常に興味深いことがわかりました。Google に送信される URL は次のとおりです。
http://www.google.com:80/calendar/feeds/mywebsite.com_f7j5nudhqc8p7suju8svd2gl8s@group.calendar.google.com/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/mywebsite.com_f7j5nudhqc8p7suju8svd2gl8s@group.calendar.google.com/private/full?orderby=starttime&singleevents=false&ctz=UTC&max-results=5000&updated-min=2011-03-14T15:17:37Z
その URL を Google Chrome に貼り付けます。希望どおり、2011-03-14T15:17:37Z 以降にすべてのイベントが更新されます。
それに基づいて、初期化コードの $scope 変数の内容を変更して、ユーザー認証用の URL を生成するのは良い考えだと思いました。
$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 = "http://www.google.com/calendar/feeds";
に
$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 時間のデバッグとグーグル検索の後、アイデアが尽きてしまいました! どうすればいいのかわからない。アイデアや回避策は大歓迎です。
ありがとう、
ダン