<i id='oHHBk'><tr id='oHHBk'><dt id='oHHBk'><q id='oHHBk'><span id='oHHBk'><b id='oHHBk'><form id='oHHBk'><ins id='oHHBk'></ins><ul id='oHHBk'></ul><sub id='oHHBk'></sub></form><legend id='oHHBk'></legend><bdo id='oHHBk'><pre id='oHHBk'><center id='oHHBk'></center></pre></bdo></b><th id='oHHBk'></th></span></q></dt></tr></i><div id='oHHBk'><tfoot id='oHHBk'></tfoot><dl id='oHHBk'><fieldset id='oHHBk'></fieldset></dl></div>

<tfoot id='oHHBk'></tfoot>
    • <bdo id='oHHBk'></bdo><ul id='oHHBk'></ul>

    <small id='oHHBk'></small><noframes id='oHHBk'>

  • <legend id='oHHBk'><style id='oHHBk'><dir id='oHHBk'><q id='oHHBk'></q></dir></style></legend>

        如何使用 Gmail API 检查收到的新邮件

        How to check for incoming new messages using Gmail API(如何使用 Gmail API 检查收到的新邮件)
          <bdo id='hsBRq'></bdo><ul id='hsBRq'></ul>

          <i id='hsBRq'><tr id='hsBRq'><dt id='hsBRq'><q id='hsBRq'><span id='hsBRq'><b id='hsBRq'><form id='hsBRq'><ins id='hsBRq'></ins><ul id='hsBRq'></ul><sub id='hsBRq'></sub></form><legend id='hsBRq'></legend><bdo id='hsBRq'><pre id='hsBRq'><center id='hsBRq'></center></pre></bdo></b><th id='hsBRq'></th></span></q></dt></tr></i><div id='hsBRq'><tfoot id='hsBRq'></tfoot><dl id='hsBRq'><fieldset id='hsBRq'></fieldset></dl></div>

              <tfoot id='hsBRq'></tfoot>
                1. <legend id='hsBRq'><style id='hsBRq'><dir id='hsBRq'><q id='hsBRq'></q></dir></style></legend>

                  <small id='hsBRq'></small><noframes id='hsBRq'>

                    <tbody id='hsBRq'></tbody>

                2. 本文介绍了如何使用 Gmail API 检查收到的新邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我已经设置了一个可以从 Gmail 帐户中提取数据的 python 脚本,但我想将其设置为自上次调用 API 以来它只会提取新消息(我将 ping服务器定期).

                  I have set up a python script that can pull data from Gmail account, but I would like to set it up in a way that it would only pull new message since the last time I made the API call (I will be pinging the server regularly).

                  我查看了推送通知和 Pub/Sub,但我不太确定这些是否相关,或者我应该查看其他内容.Gmail 也有 Users.history: list 功能,但我想知道这是否可以以任何有用的方式使用.

                  I have looked at Push notification and Pub/Sub, but I am not quite sure if these are relevant or I should be looking at something else. Gmail also has Users.history: list function, but I am wondering if this can be used in any useful way.

                  推荐答案

                  你可以 列出消息 就像你通常做的那样,但是说你想要某个时间戳之后的消息.这样,您可以轮询新消息,例如每分钟,给出你最后一次检查消息的时间,以 自纪元以来的秒数:

                  You could list messages as you usually do, but saying that you want messages after a certain timestamp. This way, you can poll for new messages e.g. every minute, giving the last time you checked for messages in seconds since the epoch:

                  请求

                  q = is:unread AND after:<time_since_epoch_in_seconds>
                  
                  GET https://www.googleapis.com/gmail/v1/users/me/messages?q=is%3Aunread+AND+after%3A1446461721&access_token={YOUR_API_KEY}
                  

                  回应

                  {
                   "messages": [
                    {
                     "id": "150c7d689ef7cdf7",
                     "threadId": "150c7d689ef7cdf7"
                    }
                   ],
                   "resultSizeEstimate": 1
                  }
                  

                  然后你只保存发出请求时的时间戳,一分钟后使用这个时间戳.

                  Then you just save the timestamp when you issued the request, and use this timestamp one minute later.

                  这篇关于如何使用 Gmail API 检查收到的新邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Running .jl file from R or Python(从 R 或 Python 运行 .jl 文件)
                  Running Julia .jl file in python(在 python 中运行 Julia .jl 文件)
                  Using PIP in a Azure WebApp(在 Azure WebApp 中使用 PIP)
                  How to run python3.7 based flask web api on azure(如何在 azure 上运行基于 python3.7 的烧瓶 web api)
                  Azure Python Web App Internal Server Error(Azure Python Web 应用程序内部服务器错误)
                  Run python dlib library on azure app service(在 azure app 服务上运行 python dlib 库)
                    <tbody id='8BV2u'></tbody>
                  <tfoot id='8BV2u'></tfoot>
                  <legend id='8BV2u'><style id='8BV2u'><dir id='8BV2u'><q id='8BV2u'></q></dir></style></legend>

                        <bdo id='8BV2u'></bdo><ul id='8BV2u'></ul>
                      • <i id='8BV2u'><tr id='8BV2u'><dt id='8BV2u'><q id='8BV2u'><span id='8BV2u'><b id='8BV2u'><form id='8BV2u'><ins id='8BV2u'></ins><ul id='8BV2u'></ul><sub id='8BV2u'></sub></form><legend id='8BV2u'></legend><bdo id='8BV2u'><pre id='8BV2u'><center id='8BV2u'></center></pre></bdo></b><th id='8BV2u'></th></span></q></dt></tr></i><div id='8BV2u'><tfoot id='8BV2u'></tfoot><dl id='8BV2u'><fieldset id='8BV2u'></fieldset></dl></div>

                          <small id='8BV2u'></small><noframes id='8BV2u'>