Gmail API所有邮件 [英] Gmail API all messages
问题描述
我需要使用gmail api获取收件箱中的所有消息.但是我只看到一种方法.
I need to get all messages in Inbox with gmail api. But I see only one way to do it.
-
获取消息列表( id,threadID )
GET https://www.googleapis.com/gmail/v1/users/somebody%40gmail.com/messages?labelIds=INBOX&key={YOUR_API_KEY}
具有id的用户会循环获取所有消息
With id`s get all messages in loop
While
GET https://www.googleapis.com/gmail/v1/users/somebody%40gmail.com/messages/147199d21bbaf5a5?key={YOUR_API_KEY}
End of While
但是,这种方式需要100500请求. 有没有人知道如何通过一个请求获得所有消息(或者只是 payload 字段)?
But for this way needed 100500 request. Have anybody idea how to get with one request all messages(or just payload field)?
推荐答案
使用批处理并一次请求100条消息.您将需要发出1000个请求,但好消息是,这很好,而且每个人都将更加轻松(一次请求中无需下载1GB响应!).
Use batch and request 100 messages at a time. You will need to make 1000 requests but the good news is that's quite fine and it'll be easier for everyone (no downloading 1GB response in a single request!).
记录在: https://developers.google.com/gmail/api/guides/batch
还有其他一些人在Stack Overflow上询问有关批处理Gmail Api的问题,因此只需快速搜索即可找到答案和示例.
There's a few other people that have asked about batching Gmail Api here on Stack Overflow, so just do a quick search to find answers and examples.
这篇关于Gmail API所有邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!