获取 Google API Resources/Rooms 的推送通知
Getting Google API Push Notifications for Resources/Rooms
我正在尝试让 Google 日历推送通知为资源(又名房间)工作。它们非常适用于用户日历,但是当我 call/watch 在资源上时,它会成功创建。我在服务器上收到了最初的 "Sync" 呼叫,但后来我再也没有收到 Google 的回复。
我创建手表的方法是对管理员进行身份验证,并使用该令牌将手表添加到管理员作为日历添加到他的列表的资源上,因此它显示在 calendarList/list 称呼。我还在该日历的管理员帐户上打开了所有通知。
知道我可能做错了什么吗?
确保您注册了接收域 URL。如果您计划使用 https://domain.com/notifications
作为您的接收 URL,您需要注册 https://domain.com.
每个可观看 Google 日历 API 资源都有一个关联的 watch
以下形式的 URI 中的方法:
https://www.googleapis.com/apiName/apiVersion/resourcePath/watch
您需要向资源的监视方法发送 POST 请求,以便为有关特定资源更改的消息设置通知渠道。
POST https://www.googleapis.com/calendar/v3/calendars/my_calendar@gmail.com/events/watch
Authorization: Bearer auth_token_for_current_user
Content-Type: application/json
{
"id": "01234567-89ab-cdef-0123456789ab", // Your channel ID.
"type": "web_hook",
"address": "https://domain.com/notifications", // Your receiving URL.
...
"token": "target=myApp-myCalendarChannelDest", // (Optional) Your channel token.
"expiration": 1426325213000 // (Optional) Your requested channel expiration time.
}
}
每个通知渠道都与特定用户和特定资源(或资源集)相关联。除非当前用户拥有或有权访问此资源,否则 watch
请求不会成功。
检查此 documentation。
我正在尝试让 Google 日历推送通知为资源(又名房间)工作。它们非常适用于用户日历,但是当我 call/watch 在资源上时,它会成功创建。我在服务器上收到了最初的 "Sync" 呼叫,但后来我再也没有收到 Google 的回复。
我创建手表的方法是对管理员进行身份验证,并使用该令牌将手表添加到管理员作为日历添加到他的列表的资源上,因此它显示在 calendarList/list 称呼。我还在该日历的管理员帐户上打开了所有通知。
知道我可能做错了什么吗?
确保您注册了接收域 URL。如果您计划使用 https://domain.com/notifications
作为您的接收 URL,您需要注册 https://domain.com.
每个可观看 Google 日历 API 资源都有一个关联的 watch
以下形式的 URI 中的方法:
https://www.googleapis.com/apiName/apiVersion/resourcePath/watch
您需要向资源的监视方法发送 POST 请求,以便为有关特定资源更改的消息设置通知渠道。
POST https://www.googleapis.com/calendar/v3/calendars/my_calendar@gmail.com/events/watch
Authorization: Bearer auth_token_for_current_user
Content-Type: application/json
{
"id": "01234567-89ab-cdef-0123456789ab", // Your channel ID.
"type": "web_hook",
"address": "https://domain.com/notifications", // Your receiving URL.
...
"token": "target=myApp-myCalendarChannelDest", // (Optional) Your channel token.
"expiration": 1426325213000 // (Optional) Your requested channel expiration time.
}
}
每个通知渠道都与特定用户和特定资源(或资源集)相关联。除非当前用户拥有或有权访问此资源,否则 watch
请求不会成功。
检查此 documentation。