Gmail 推送通知不会停止
Gmail push notifications does not stop
我正在使用 "WATCH" 请求将我的电子邮件连接到 pub/sub API。但是当我要使用下面的代码(由 Google 提供)停止通知时,它不起作用。我正在使用 python 客户端。
credentials = get_credentials()
http = credentials.authorize(httplib2.Http())
service = discovery.build('gmail', 'v1', http=http)
result = service.users().stop(userId='me')
我的参考资料:
result = service.users().stop(userId='me').execute()
您忘记了 execute 方法,除非您调用 execute 方法,否则您的语句什么都不做。
这里有一个关于如何使用 google api 的小指南。去 https://developers.google.com/gmail/api/quickstart/python and observe the code, service.users().labels().list(userId='me').execute()
then go to Google API Explorer and select your service let's say Gmail API you want to use https://developers.google.com/apis-explorer/#p/gmail/v1/ ,在那里你会看到服务和描述,像这样
gmail.users.labels.list
这里的gmail是你python代码中的服务对象,剩下的就是方法,execute对应本页这里的execute按钮https://developers.google.com/apis-explorer/#p/gmail/v1/gmail.users.labels.list
我正在使用 "WATCH" 请求将我的电子邮件连接到 pub/sub API。但是当我要使用下面的代码(由 Google 提供)停止通知时,它不起作用。我正在使用 python 客户端。
credentials = get_credentials()
http = credentials.authorize(httplib2.Http())
service = discovery.build('gmail', 'v1', http=http)
result = service.users().stop(userId='me')
我的参考资料:
result = service.users().stop(userId='me').execute()
您忘记了 execute 方法,除非您调用 execute 方法,否则您的语句什么都不做。
这里有一个关于如何使用 google api 的小指南。去 https://developers.google.com/gmail/api/quickstart/python and observe the code, service.users().labels().list(userId='me').execute()
then go to Google API Explorer and select your service let's say Gmail API you want to use https://developers.google.com/apis-explorer/#p/gmail/v1/ ,在那里你会看到服务和描述,像这样
gmail.users.labels.list
这里的gmail是你python代码中的服务对象,剩下的就是方法,execute对应本页这里的execute按钮https://developers.google.com/apis-explorer/#p/gmail/v1/gmail.users.labels.list