gpt4 book ai didi

gmail - 仅在收到新邮件时接收Gmail推送通知

转载 作者:行者123 更新时间:2023-12-04 08:55:05 25 4
gpt4 key购买 nike

我正在尝试制作一个应用程序,以查找收件人是否已经使用GMAIL的推送通知回复了我的电子邮件。
它运作良好,但问题是,我收到有关Gmail更改的通知。

这是我使用的代码

request = {
'labelIds': ['UNREAD'],
'topicName': topic,
'labelFilterAction': 'include'
}
service.users().watch(userId=user.google_id, body=request).execute()

然后我尝试使用'labelFilterAction':'exclude'
system_labels = ['CATEGORY_UPDATES', 'UNREAD', 'DRAFT', 'CATEGORY_PROMOTIONS', 'INBOX', 'CATEGORY_SOCIAL', 'CATEGORY_PERSONAL', 'CATEGORY_FORUMS', 'TRASH', 'CHAT', 'IMPORTANT', 'SENT', 'STARRED', 'SPAM']
system_labels.remove('UNREAD')
request = {
'labelIds': system_labels,
'topicName': topic,
'labelFilterAction': 'exclude'
}
service.users().watch(userId=user.google_id, body=request).execute()

有了这个,我根本没有收到任何通知。
有什么建议吗?

最佳答案

工作的Python代码

credentials = get_credentials(email)
http = credentials.authorize(httplib2.Http())
service = discovery.build('gmail', 'v1', http=http)

request = {
'labelIds': ['CATEGORY_PERSONAL'],
'topicName': 'projects/myproject/topics/getNotification',
'labelFilterAction': 'exclude'
}
service.users().watch(userId='me',body=request).execute()

关于gmail - 仅在收到新邮件时接收Gmail推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31718427/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com