I have already login through GoogleApiClient in my application.
I am also able to List of email matching query using google api sample.
users.messages.list 通过此链接,我收到带有查询文本(搜索词)的用户电子邮件。
1.我需要使用gmail api收到上一封电子邮件。
答案 0 :(得分:2)
Listing只是问题的一半:
请求强>
maxResults = 1
q = -from:me
GET https://www.googleapis.com/gmail/v1/users/me/messages?maxResults=1&q=-from%3Ame&access_token={YOUR_API_KEY}
<强>响应强>
{
"messages": [
{
"id": "1520a62ee385565e",
"threadId": "1520a62ee385565e"
}
],
"nextPageToken": "17704551804303833190",
"resultSizeEstimate": 1
}
之后,您需要Get特定的电子邮件:
请求强>
GET https://www.googleapis.com/gmail/v1/users/me/messages/1520a62ee385565e?access_token={YOUR_API_KEY}
<强>响应强>
{
"id": "1520a62ee385565e",
"threadId": "1520a62ee385565e",
"labelIds": [
"INBOX",
"CATEGORY_SOCIAL",
"UNREAD"
],
"snippet": "Snippet of the message",
"historyId": "701108",
"internalDate": "1451873198000",
"payload": {
"mimeType": "multipart/alternative",
...