如何获取最旧的消息ID GMAIL API [英] How to get oldest message id GMAIL API
本文介绍了如何获取最旧的消息ID GMAIL API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用来获取message_ID users_messages-> listusersmessages
的列表.有没有办法获取最早的message_ID?
I'm using to get the list of message_ID users_messages->listusersmessages
. Is there a way to get the oldest message_ID?
推荐答案
您目前无法指定列出消息的顺序.您必须列出每条消息,直到获得邮件ID的最后一页:
You can not specify the order in which to list messages, at this time. You will have to list every message until you get the last page of message ids:
请求1
GET https://www.googleapis.com/gmail/v1/users/me/messages?access_token={YOUR_ACCESS_TOKEN}
响应1
{
"messages": [
{
"id": "155fd69a74bceff0",
"threadId": "155fd69a74bceff0"
}, ...
],
"nextPageToken": "03259718007012574564",
"resultSizeEstimate": 103
}
使用 nextPageToken
,并继续列出消息,直到响应中没有 nextPageToken
.
Use the nextPageToken
, and continue to list messages until there is no nextPageToken
in the response.
请求2
GET https://www.googleapis.com/gmail/v1/users/me/messages?pageToken=03259718007012574564&access_token={YOUR_ACCESS_TOKEN}
响应2
{
"messages": [
{
"id": "155772ef5633f85b",
"threadId": "155772ef5633f85b"
},
...,
{
"id": "1557460c0e3b5a89",
"threadId": "1557460c0e3b5a89"
}
],
"resultSizeEstimate": 103
}
此响应没有 nextPageToken
,因此 1557460c0e3b5a89
是最后一个.
This response has no nextPageToken
, so 1557460c0e3b5a89
is the last one.
这篇关于如何获取最旧的消息ID GMAIL API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文