如何使用 gmail api 检测已读未读邮件?

How can I detect read unread mails using gmail api?

我正在开发一个邮箱应用程序,我收到以下响应作为 "GTLGmailMessage" 对象的 gmail 邮件,如下所示:- 我浏览了 api 文档,但找不到任何解决方案。

有什么方法可以检测邮件是否已读。

{
historyId = 80237;
id = 152589a56bea2515;
internalDate = 1453185455000;
labelIds =     (
    INBOX,
    IMPORTANT,
    "CATEGORY_UPDATES"
);
payload =     {
    body =         {
        data = DQp———— — dG9bmtzIQ0K;
        size = 732;
    };
    filename = "";
    headers =         (
                    {
            name = "Delivered-To";
            value = "hussain@walkover.in";
        },
                    {
            name = Received;
            value = "by 10.37.100.68 with SMTP id y65csp2443890ybb;        Mon, 18 Jan 2016 22:37:35 -0800 (PST)";
        },
                    {
            name = "X-Received";
            value = "by 10.13.239.129 with SMTP id y123mr16831747ywe.167.1453185455680;        Mon, 18 Jan 2016 22:37:35 -0800 (PST)";
        },
                    {
            name = "Return-Path";
            value = "<noreply@github.com>";
        },
                    {
            name = Received;
            value = "from github-smtp2b-ext-cp1-prd.iad.github.net (github-smtp2-ext3.iad.github.net. [192.30.252.194])        by mx.google.com with ESMTPS id q63si16585388ywb.331.2016.01.18.22.37.35        for <hussain@walkover.in>        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);        Mon, 18 Jan 2016 22:37:35 -0800 (PST)";
        },
                    {
            name = "Received-SPF";
            value = "pass (google.com: domain of noreply@github.com designates 192.30.252.194 as permitted sender) client-ip=192.30.252.194;";
        },
                    {
            name = "Authentication-Results";
            value = "mx.google.com;       spf=pass (google.com: domain of noreply@github.com designates 192.30.252.194 as permitted sender) smtp.mailfrom=noreply@github.com;       dkim=pass (test mode) header.i=@github.com;       dmarc=pass (p=NONE dis=NONE) header.from=github.com";
        },
                    {
            name = Date;
            value = "Mon, 18 Jan 2016 22:37:35 -0800";
        },
                    {
            name = "DKIM-Signature";
            value = "v=1; a=rsa-sha256; c=relaxed/relaxed; d=github.com; s=pf2014; t=1453185455; bh=PQFrfD7nxfJCQgsdom7s6/TMtuIlEPwr4GKz/BVEYNE=; h=From:To:Subject:From; b=PbKfqrQfPtJzh2YsK2RqLPahAYL8Wk40aW1GnqZqNCZp0dehGTRCByYDg4HT93m89\t NK+BbCDbcSgkiII6NnBildbsorKfenoVE2jTS21fllusq1Oflmyayo1GyRvGOkFEd1\t WCgQlsicXhXniFDza60ibwwcABXyB/yVCcnrrpGk=";
        },
                    {
            name = From;
            value = "GitHub <noreply@github.com>";
        },
                    {
            name = To;
            value = "hussain@walkover.in";
        },
                    {
            name = "Message-ID";
            value = "<569dd9af5be8b_5b613f8adf71f29c19092@github-lowworker7-cp1-prd.iad.github.net.mail>";
        },
                    {
            name = Subject;
            value = "[GitHub] Subscribed to SendOTP/iOS notifications";
        },
                    {
            name = "Mime-Version";
            value = "1.0";
        },
                    {
            name = "Content-Type";
            value = "text/plain; charset=UTF-8";
        },
                    {
            name = "Content-Transfer-Encoding";
            value = "quoted-printable";
        },
                    {
            name = "X-Auto-Response-Suppress";
            value = All;
        }
    );
    mimeType = "text/plain";
    partId = "";
};
sizeEstimate = 2601;
snippet = "Hey there, we&#39;re just writing to let you know that you&#39;ve been automatically subscribed to a";
threadId = 152589a56bea2515;

}

如何检测天气邮件是否已读。

提前致谢。

您可以在响应的 labelIds-数组中检查 UNREAD-标签。

请求

GET https://www.googleapis.com/gmail/v1/users/me/messages/152d4596db9906f8

回应

{
 "id": "152d4596db9906f8",
 "threadId": "152d4596db9906f8",
 "labelIds": [
  "SENT",
  "INBOX",
  "IMPORTANT",
  "UNREAD"
 ],
 "snippet": "Cool message, buddy.", ...
}

Read/Unread 消息的状态由未读标签的存在表示。

您可以在下面找到有关管理标签检查的信息link

Managing Labels