2016-02-12 80 views
2

我正在研究一個郵箱應用程序,並且我收到了以下響應,作爲gmail消息的「GTLGmailMessage」對象,如下所示: - 我已經瀏覽了api文檔,但找不到任何解決方案。如何檢測使用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 = "[email protected]"; 
     }, 
        { 
      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 = "<[email protected]>"; 
     }, 
        { 
      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 <[email protected]>  (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 [email protected] 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 [email protected] designates 192.30.252.194 as permitted sender) [email protected];  dkim=pass (test mode) [email protected];  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 <[email protected]>"; 
     }, 
        { 
      name = To; 
      value = "[email protected]"; 
     }, 
        { 
      name = "Message-ID"; 
      value = "<[email protected]d.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; 

}

我怎樣才能檢測天氣郵件已讀或未讀。

在此先感謝。

回答

3

您可以在響應中檢查UNREAD-labelIds -array中的標籤。

請求

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

響應

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

讀/用於消息未讀狀態由UNREAD標記的存在表示。

enter image description here

你可以找到管理標籤的信息,查看以下鏈接

Managing Labels