提问者:小点点

查找所有用户在一个线程的gmailAPI


我正在使用gmailAPI获取最近的环聊消息/线程。但是我找不到查看收件人地址的方法。payload. header中唯一的字段是“从”

代码:

curl-H'授权:承载者**访问令牌**''https://www.googleapis.com/gmail/v1/users/me/threads/**threadId**? q=is:chat'

回应:

{
"id": "xxx",
"historyId": "1008967",
"messages": [{
    "id": "xxx",
    "threadId": "xxx",
    "labelIds": [
        "CHAT"
    ],
    "snippet": "+Harry Howard",
    "historyId": "1008953",
    "internalDate": "1481641738948",
    "payload": {
        "partId": "",
        "mimeType": "text/html",
        "filename": "",
        "headers": [{
            "name": "From",
            "value": "xxx"
        }],
        "body": {
            "size": 13,
            "data": "K0hhcnJ5IEhvd2FyZA=="
        }
    },
    "sizeEstimate": 100
}]
}

对于电子邮件,有一个“收件人”字段(有时还有抄送等)。

FYI:我正在使用node-gmail-api npm模块,但只是用curl测试这个


共1个答案

匿名用户

使用User. thread:list查找线程中的所有用户。在这里看一个例子。

HTTP请求

GET https://www.googleapis.com/gmail/v1/users/userId/threads

此请求需要至少具有以下范围之一的授权

  • https://mail.google.com/
  • https://www.googleapis.com/auth/gmail.modify
  • https://www.googleapis.com/auth/gmail.readonly
  • https://www.googleapis.com/auth/gmail.metadata

回应

如果成功,此方法返回具有以下结构的响应正文:

{
  "threads": [
    users.threads Resource
  ],
  "nextPageToken": string,
  "resultSizeEstimate": unsigned integer
}

相关问题