与用于日期查询的Gmail Web UI相比,Gmail API未返回正确的电子邮件 [英] Gmail API not returning correct emails compared to Gmail web UI for date queries

查看:99
本文介绍了与用于日期查询的Gmail Web UI相比,Gmail API未返回正确的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用此处所述的标准查询格式时,Gmail api和Gmail Web ui的结果有所不同-

The results differ between the Gmail api and Gmail web ui when using the standard query format as described here - https://support.google.com/mail/answer/7190.

该问题专门用于参数after/before和newer/older.例如,与在Gmail网络用户界面中运行同一查询相比,以下Gmail api查询"2015年11月19日之后:2015/11/19"返回的结果不同. Web ui看起来正确,而api返回第二天(第20天)的电子邮件.可能是时区对话问题吗?

The issue is specifically for the parameters after/before and newer/older. For example the following Gmail api query "after:2015/11/19 before:2015/11/20" returns different results compared with running that same query in the Gmail web ui. The web ui looks correct whereas the api returns emails from the next day (20th). Possibly a timezone conversation problem?

检查过去的问题,我在这里看到类似的内容如何将GMAIL API查询过滤器用于日期时间(服务器将查询作为PST时间进行处理).在这种情况下,可能值得更新文档或考虑可能的解决方案.

Checking past questions I see something similiar here how to use GMAIL API query filter for datetime (the server processes the queries as PST time). If this is the case it might be worth updating the docs or think about a possible solution.

重现问题的步骤.

  1. 在gmail帐户中包含一些邮件,其中包含以下日期. Inc天之前和之后.
  2. 在Gmail网络用户界面中运行时间:2015/11/19之后:2015/11/20.
  3. 使用
  1. Have some mail in a gmail account covering the dates below. Inc days after and before.
  2. Run after:2015/11/19 before:2015/11/20 in a Gmail web ui.
  3. Query the Gmail api with "after:2015/11/19 before:2015/11/20" for the q parameter using https://developers.google.com/gmail/api/v1/reference/users/messages/list
  4. Compare results. (I had differences when running these steps against a UK Gmail account)

应该只看到19号的电子邮件,但是使用api时,我看到的电子邮件的日期是19号和20号. Web ui可以正常工作,并且仅返回日期为19日的电子邮件.

Should only see emails from the 19th, but I see emails dated the 19th AND 20th when using the api. The web ui works as expected and only returns emails dated the 19th.

仅供参考:我还使用了其他查询参数,例如"from:example@example.com",以及之前/之后或更新/较旧的参数.我想简化错误报告/问题.

FYI: I was also using other query parameters such as "from: example@example.com" in conjuction with before/after or newer/older params. I wanted to simplify the bug report / question.

也:我使用名为node-gmail-api的节点模块进行的api查询.检查正在使用的端点的代码是消息"代码:

Also: The api queries I was making with a node module called node-gmail-api. Checking the code the endpoint being used is 'messages' code:

body: 'GET ' + api + '/gmail/v1/users/me/messages/' + m.id + fields + '\n'

是否正在调用消息"端点而不是消息/列表"端点的问题?根据这个问题的答案? -为什么要搜索gmail API中的返回结果与gmail网站中的搜索结果不同?

Is the problem that 'messages' and not 'messages/list' endpoint is being called? As per answer to this question? - Why does search in gmail API return different result than search in gmail website?

这是错误/功能吗?是否有解决方法,例如使用纪元ms. (据我所见,也没有出现在文档中)

Is this a bug / feature? Is there a workaround such as using epoch ms. (also not in the docs as I can see)

谢谢

推荐答案

您可以列出邮件,如果您愿意,可以以第二个准确度列出:

You can list the messages with second accuracy if you would like:

q = after:<start_of_day_in_seconds> AND before:<end_of_day_in_seconds>

例如从Wed, 25 Nov 2015 00:00:00 GMTWed, 25 Nov 2015 23:59:59 GMT将是:

q = after:1448409600 AND before:1448495999

这篇关于与用于日期查询的Gmail Web UI相比,Gmail API未返回正确的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆