简体   繁体   中英

How to Create new Contact using People API with multiple values

I want to Create New Contact with multiple emails and phone numbers

i have try with one email and phone number it is working this is the code im using


$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;

Can Someone help me to modify the code to push multiple values i have go true lots of google docs but i cannot fine a way to do in php

Parogrock thank you for the answer

$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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM