Я хочу сохранить детали человека, используя API людей Google. Все работает нормально, но вместо создания нескольких объектов я хочу создать один массив и передать все значения.
<?php
require 'config.php';
try {
$service = getClient();
$person = new Google_Service_PeopleService_Person();
$name = new Google_Service_PeopleService_Name();
$name->setFamilyName('Test');
$person->setNames($name);
$email = new Google_Service_PeopleService_EmailAddress();
$email->setValue('test@test.com');
$person->setEmailAddresses($email);
$phone = new Google_Service_PeopleService_PhoneNumber();
$phone->setValue('1234567890');
$person->setPhoneNumbers($phone);
$exe = $service->people->createContact($person);
$_SESSION['alert'] = 'Contact created successfully';
} catch(Exception $e) {
$msg = json_decode( $e->getMessage() );
$_SESSION['alert'] = $msg->error->message;
}
header('location:index.php');
?>