我们可以使用云接收多个用户的 gmail 推送通知到同一个推送端点 pub/sub
Can we receive gmail push notifications for multiple users to same push end point using cloud pub/sub
我已经在 java 中实现了用于接收 gmail 推送通知的代码。对于邮件 ID,我在其中创建了项目、主题和订阅,它工作得很好。通知发布到我提到的 URL,我可以获取通知的数据。但我想收到多个用户关于同一主题和同一推送端点 url 的通知,我已将其用于一个邮件 ID。这可能吗?
Watch request
To configure Gmail accounts to send notifications to your Cloud Pub/Sub topic, simply use your Gmail API client to call watch() on the Gmail user mailbox similar to any other Gmail API call. To do so, provide the topic name created above and any other options in your watch() request, such as labels to filter on. For example, to be notified any time a change is made to the Inbox:
要求:
POST "https://www.googleapis.com/gmail/v1/users/{UserId}/watch"
Content-type: application/json
{
topicName: "projects/myproject/topics/mytopic",
labelIds: ["INBOX"],
}
回应
{
historyId: 1234567890
expiration: 1431990098200
}
每个观看请求针对单个用户。如果您想要一个以上的用户使用它,那么您必须将其设置为观看您感兴趣的每个用户。
我已经在 java 中实现了用于接收 gmail 推送通知的代码。对于邮件 ID,我在其中创建了项目、主题和订阅,它工作得很好。通知发布到我提到的 URL,我可以获取通知的数据。但我想收到多个用户关于同一主题和同一推送端点 url 的通知,我已将其用于一个邮件 ID。这可能吗?
Watch request To configure Gmail accounts to send notifications to your Cloud Pub/Sub topic, simply use your Gmail API client to call watch() on the Gmail user mailbox similar to any other Gmail API call. To do so, provide the topic name created above and any other options in your watch() request, such as labels to filter on. For example, to be notified any time a change is made to the Inbox:
要求:
POST "https://www.googleapis.com/gmail/v1/users/{UserId}/watch"
Content-type: application/json
{
topicName: "projects/myproject/topics/mytopic",
labelIds: ["INBOX"],
}
回应
{
historyId: 1234567890
expiration: 1431990098200
}
每个观看请求针对单个用户。如果您想要一个以上的用户使用它,那么您必须将其设置为观看您感兴趣的每个用户。