4

次のように、JS クライアント ライブラリを使用してカレンダー イベント通知をサブスクライブしようとしています。

gapi.client.load('calendar', 'v3', function () {
            var request = gapi.client.calendar.events.watch({
                'calendarId': cl.gCalendarID,
                'id': unid,
                'type': "web_hook",
                'address': {my url here}
            });
            request.execute(function (resp) {
                console.log(resp);
            });
        });

Entity.Resourceしかし、「 」という役に立たないメッセージとともに 400 が返され続けています。

私が得る応答のデータオブジェクトでDomain:global, Message: Entity.Resource, reason: Required"

私はすでに oauth2 で認証されており、Google アカウントでアクセスを許可されており、カレンダーのリストを正常に取得でき、それらのカレンダーからイベントを取得していますが、時計を購読するこの方法は機能しませんか? これについてGoogleで何も見つけられないのを助けてください。

4

2 に答える 2

6
Instead of this:


 var request = gapi.client.calendar.events.watch({
                'calendarId': cl.gCalendarID,
                'id': unid,
                'type': "web_hook",
                'address': {my url here}
            });

次の構文を使用します。

calendar.events.watch({
            auth: auth,
                resource: {
                    id: "12345",
                    type: 'web_hook',
                    address: {mu url here}
                 },
                calendarId: 'primary' 

            }, function(err, response) {
                if (err) {
                    logger.MessageQueueLog.log("info","index.js:- watchnotification(),Error in Watch Notification: " + err);

                } else {          
                   logger.MessageQueueLog.log("info","index.js:- watchnotification(), Notification : " + JSON.stringify(response));           

                }
            });

それがうまくいくことを願っています。

于 2016-03-02T09:04:46.383 に答える
0

以下のように、リクエストを互いに区別するために、Calendar API に対するリクエストでトークン値を渡す必要があります。

{
  "id": string,
  "token": string,
  "type": string,
  "address": string,
  "params": {
  "ttl": string
 }
}

詳細については、次を参照してください。

Google カレンダー API

于 2015-01-14T12:38:44.907 に答える