- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用以下查询:
No Man's Sky
与 API Explorer 和我的 C# 应用程序相比,我从 Web UI 获得了不同的结果。
请注意,对话 View 已禁用:
如果启用对话 View ,Web UI 会返回 9 个线程;使用线程 API,我得到 7 个线程。
{
"messages": [
{
"id": "15686dcf7989e60f"
},
{
"id": "1566bce4412a439d"
},
{
"id": "156327e51b979f48"
},
{
"id": "1560f0caf9297ab9"
},
{
"id": "155f01dba1c3ad77"
},
{
"id": "1538bce006a95a84"
},
{
"id": "15342e9d99b4d3f6"
}
]
}
我看到的结果与我的 C# 应用程序中的 API 资源管理器相同。 API 和 Web UI 之间似乎存在脱节。 Web UI 返回 10 个结果,而 API 仅返回这 10 个结果中的 7 个(我已手动验证它们是 10 个结果的子集)。
事实证明,API 将查询视为文字。将 Web UI 中的查询用引号括起来给出与 API 相同的结果。
这确实留下了如何使用 API 复制原始搜索的问题;是否必须运行 3 个查询然后只获取所有 3 个中返回的结果?当您开始处理复杂的查询时,这会变成一件繁琐的解析工作。
我尝试通过分别运行 3 个 ANDed 术语来复制 Web UI 结果,然后提取结果,其中消息 ID 是所有 3 个查询的结果集,我得到了与 API 调用相同的 7 个结果。
用于测试的代码:
var service = GMailServiceManager.Instance.Service;
var resultsNo = GMailUtils.GetItems(service, null, "No", true);
var resultsMans = GMailUtils.GetItems(service, null, "Man's", true);
var resultsSky = GMailUtils.GetItems(service, null, "Sky", true);
var anded = from nos in resultsNo.Items
from manses in resultsMans.Items
from skys in resultsSky.Items
where nos.Id == manses.Id && nos.Id == skys.Id
select nos.Id;
GMailUtils.GetItems()
只是处理 API 请求的批处理和一些其他特定于应用程序的例程。它使用以下方法检索批处理中的每组项目:
UsersResource.MessagesResource.ListRequest request = service.Users.Messages.List("me");
request.Q = search;
request.Fields = "messages(id),nextPageToken";
request.PageToken = pageToken;
// Logging and batching here
...
request.Execute();
...
我现在不知道 Web UI 是如何产生其他点击的; www.no-mans-sky.com
中的两个实例(它们在同一个线程中)突出显示了命中:
另一个在电子邮件中分别点击了 No
Man
和 Sky
(注意不是 Man 的)。
回到 Web UI,我决定对搜索词 Man's
进行一些测试。
在 Web UI 中,我获得了数百次点击:
对于 “Man's”
,我得到 11 次匹配:
API 与引用的 Web UI 匹配:
{
"messages": [
{
"id": "15686dcf7989e60f"
},
{
"id": "1566bce4412a439d"
},
{
"id": "156327e51b979f48"
},
{
"id": "1560f0caf9297ab9"
},
{
"id": "155f01dba1c3ad77"
},
{
"id": "1538bce006a95a84"
},
{
"id": "15342e9d99b4d3f6"
},
{
"id": "13da4a6d7a4159b2"
},
{
"id": "13da4a502eca7dff"
},
{
"id": "12e70fbf3d655ac8"
},
{
"id": "1278adc3ed72f6a8"
}
]
}
基于此,API 的查询似乎被视为字符串文字而不是 Web UI 样式的查询。对我来说似乎是一个错误,因为我找不到使用 API 重现 Web UI 结果的方法。
最佳答案
我用我自己的 Gmail 试了一下,我发现有些电子邮件是在一个线程中找到的。
这是我的例子:
我使用了单词 time tracker 作为我的主题,Gmail 用户界面为我提供了 4 封电子邮件的结果。但是如果你算上总的结果,它给了我一共 12 个结果。 A 6 封,B 3 封,C 2 封,D 1 封邮件。
所以如果我使用请求
GET https://www.googleapis.com/gmail/v1/users/example%40google.com/messages?q=subject%3A(time+tracker)&fields=messages(id%2CthreadId)&key={YOUR_API_KEY}
或 Try it part在 Gmail API 中,
它会像在 GMail UI 中那样给我一个包含 12 个 ID 的结果。
查看上图,您会注意到属于同一线程的所有电子邮件都具有相同的 threadId
。
因此尝试使用 threadId
来确定在您的请求中找到的电子邮件数量。如果我误解了这个问题,请有人告诉我。
关于gmail-api - GMail v1 API Users.messages 结果与逻辑 AND/OR 上的 Web UI 不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38960331/
我是一名优秀的程序员,十分优秀!