You need to enable JavaScript to run this app. Google People API中批量创建联系人使用的类名是什么?
优惠活动
大模型
产品
解决方案
定价
更多

Google People API中批量创建联系人使用的类名是什么?

Google People API 批量创建联系人需要使用的类

你需要使用 Google_Service_PeopleService_PeopleBatchCreateContactsRequest 类来构造批量请求,配合客户端的 batchCreateContacts 方法完成批量创建操作,单次请求最多支持同时创建200个联系人。

参考实现代码

// 批量构造所有需要创建的联系人对象
$personList = [];
foreach ($create_data as $item) {
    $personList[] = new Google_Service_PeopleService_Person($item);
}

// 构造批量创建请求对象
$batchCreateRequest = new Google_Service_PeopleService_PeopleBatchCreateContactsRequest();
$batchCreateRequest->setContacts($personList);
// 按需指定需要返回的联系人字段,必填参数,不可省略
$batchCreateRequest->setPersonFields('names,phoneNumbers,emailAddresses,addresses');

// 执行批量创建请求
$response = $service->people->batchCreateContacts($batchCreateRequest);

注意事项

  • 单次批量请求的联系人数量上限为200,超过该数值需要拆分多批分别请求
  • setPersonFields 为必填参数,需要根据你实际需要返回的联系人属性配置对应字段,缺省会触发参数校验错误

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.16 06:45:00