How to get the number of unread threads in INBOX with Gmail API?

前端 未结 3 1793
悲哀的现实
悲哀的现实 2021-01-21 01:42

I tried to use the list thread method:

GET https://www.googleapis.com/gmail/v1/users/{MyEmailAddress}/threads?labelIds=INBOX&labelIds=UNREAD&key={YOUR_AP         


        
3条回答
  •  一向
    一向 (楼主)
    2021-01-21 02:42

    GET https://www.googleapis.com/gmail/v1/users/{email}/messages?labelIds=UNREAD&labelIds=INBOX&fields=messages%2FthreadId
    

    "messages/threadId" will count the number of unread threads but will list the same thread multiple times if the thread has multiple messages. Store them in an array and check the array as you fill it for matching "threadId" identifiers and ignore duplicates.

提交回复
热议问题