我正在为我的一个iOS应用程序使用Gmail API。Gmail API。我成功授权用户登录过程。然后我得到了所有邮件的列表(Users.threads.list),结果如下所示。
现在我需要收到带附件的邮件(User.messages.attachment.get)。为此,我需要传递3个参数,即emailId,messageId,id。
我的问题是"如何获得此信息"?
由于 :)
答案 0 :(得分:3)
您在第一个请求中获得的threadId是标识线程的Id,与线程中的第一条消息相同。它与附件无关。
我收件箱中的最新消息有一个附件。我将通过列出邮件来获取它:
GET https://www.googleapis.com/gmail/v1/users/me/messages?maxResults=1&access_token={YOUR_API_KEY}
<强>响应:强>
{
"messages": [
{
"id": "14e8bf63dd00a52f", // This is the message id!
"threadId": "14e8bf63dd00a52f" // Since it is the first message in the thread,
// the threadId is the same.
}
],
"nextPageToken": "01097010197696465829",
"resultSizeEstimate": 3
}
然后我使用此ID来获取消息&quot; attachmentId:
GET https://www.googleapis.com/gmail/v1/users/me/messages/14e8bf63dd00a52f?fields=payload%2Fparts%2Fbody%2FattachmentId&format=full&access_token={YOUR_API_KEY}
<强>响应:强>
{
"payload": {
"parts": [
{
"body": {
"attachmentId": "ANGjdJ9UyXwpB8pVWgFrzmC3UN92YdlMTEF2-At-0zWG88keYXomvYLxZFMoOq7YVC-14VbOqgssCueyDzo103M28HNnUAC-2KSNF5yIK_74BuNqlMXCUar3OFAwVjsS8s8nWQjkreVusTB5Y4XhHNaj7Z7cCKuRFQBSABLfCF75boSHvHSD1RDeOI33e-7y-1JAgn3VN-AFrOQKVEsclVr_QHt2298tLRhyVzJ30ePnOFnZoyaP_uP54XZHMxXsm9YdfzVKtwFiwqlm4IYjQYX5_eNWUaeqbemBot43fQ"
}
}
]
}
}
然后,最后,我使用消息的ID和attachmentId来获取附件:
GET https://www.googleapis.com/gmail/v1/users/me/messages/14e8bf63dd00a52f/attachments/ANGjdJ9UyXwpB8pVWgFrzmC3UN92YdlMTEF2-At-0zWG88keYXomvYLxZFMoOq7YVC-14VbOqgssCueyDzo103M28HNnUAC-2KSNF5yIK_74BuNqlMXCUar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