【问题标题】:How to Create new Contact using People API with multiple values如何使用具有多个值的 People API 创建新联系人
【发布时间】:2019-06-12 07:49:38
【问题描述】:

我想使用多个电子邮件和电话号码创建新联系人

我尝试了一个电子邮件和电话号码,它正在工作这是我正在使用的代码


$name = new Google_Service_PeopleService_Name();
$name->setGivenName('00nirman');
$name->setFamilyName('weerasinghe');
$person->setNames($name);
$email1 = new Google_Service_PeopleService_EmailAddress();
$email1->setValue('test@example.com');
$person->setEmailAddresses($email1);

$phone1 = new Google_Service_PeopleService_PhoneNumber();
$phone1->setValue('0777677305');
$phone1->setType('home');
$person->setPhoneNumbers($phone1);
$exe = $people_service->people->createContact($person)->execute;

有人可以帮我修改代码以推送多个值吗?

【问题讨论】:

  • 你不能将电话号码数组传递给 Person::setPhoneNumbers 吗?
  • 我试过这个 $phone1 = new Google_Service_PeopleService_PhoneNumber(array('value'=>'0777677305'), array('value'=>'0774112128') );不工作
  • 怎么样:$person->setPhoneNumbers([$phone1, $phone2]);?

标签: php google-api google-people-api


【解决方案1】:

Parrogrock 谢谢你的回答

$phone1 = new Google_Service_PeopleService_PhoneNumber();
$phone2 = new Google_Service_PeopleService_PhoneNumber();
$phone1->setValue('0777677305');
$phone2->setValue('0774112128');

$person->setPhoneNumbers([$phone1,$phone2]);

$exe = $people_service->people->createContact($person)->execute;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-26
    • 2021-09-19
    • 2021-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多