You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用People API的searchContacts()查询邮箱结果不稳定,是否故障?

关于Google People API searchContacts()查询邮箱不稳定的问题

我开发了一个个人Apps Script,用于从电子表格提取联系人信息,检查该联系人是否已存在于我的Google联系人中,并根据结果添加或修改联系人。目前脚本整体功能已实现,但调用People API的.searchContacts()方法查询邮箱地址时,结果始终不稳定。查阅官方文档及相关技术帖子后仍无法解决问题,考虑到有资料显示电话号码查询存在故障,我怀疑邮箱查询也存在类似问题。

相关代码片段

邮箱查询函数

function checkEmailExists(email) {
    var personObject = People.People.searchContacts({
      "query": email.toString(),
      "readMask": "emailAddresses,memberships"
    });
  return personObject;
}   

注:邮箱地址从数组对象提取,已转为字符串后传入查询。

预热查询逻辑

Logger.log('Email to check: ' + contact.email);
var personObjectByEmail = checkEmailExists("");
    Logger
      .log('Run warmup of checking for contact...')
      .log(personObjectByEmail);
    Utilities.sleep(5000);
var personObjectByEmail = checkEmailExists(contact.email);
    Logger
      .log('Check for actual contact e-mail.')
      .log(personObjectByEmail);
// 若返回空对象`{}`则判定联系人不存在,调用addToContacts()添加(该函数工作正常,可成功添加联系人到Google Contacts)

日志结果

Log Results
1:25:23 PM Info Email to check: example@gmail.com
1:25:23 PM Info Check if email exists in contacts...
1:25:23 PM Info Run warmup of checking for contact...
1:25:23 PM Info {}
1:25:28 PM Info Check for actual contact e-mail.
1:25:28 PM Info {}

疑问与诉求

待查询邮箱确实已存在于我的Google联系人中,但调用.searchContacts()多数时候返回空对象{},偶尔能返回正常结果,导致脚本重复添加联系人。我不确定是自身代码问题,还是该API的邮箱查询功能存在故障。虽然可以通过拉取全部联系人列表自行搜索,但希望能使用该方法简化代码。

内容的提问来源于stack exchange,提问作者Corinne Jacobo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 12:12:10