Reputation: 43
for 3 days i'm frustated because google not have tutorial for php. (sorry for my bad english)
i got an error while updating names :
$client=client_google();
$google_id="people/c3062123412341234";
if ($client->getAccessToken() == "") return null;
$people_service = new Google_Service_PeopleService($client);
$person = new Google_Service_PeopleService_Person();
if($tipenya == "Cancel"){
$name = new Google_Service_PeopleService_Name();
$name->SetFamilyName("Keluarga Cemara");
$name->SetGivenName("Tampan");
$person->setNames($name);
$profile = $people_service->people->get(
$google_id,
array('personFields' => 'metadata'));
$etag = $profile->etag;
$person->setEtag($etag);
$person->setResourceName($google_id);
if($google_id !=''){
//$people_service->people->updatePersonField("names");
$people_service->people->updateContact($google_id,$person);
}
}else if($tipenya=="Delete"){
if($google_id !=''){
$person->setResourceName($google_id);
$people_service->people->deleteContact($person);
}
}
Error when i execute:
exception 'Google_Service_Exception' with message '{ "error": { "code": 400, "message": "updatePersonFields mask is required. Please specify one or more valid paths. Valid paths are documented at https://developers.google.com/people/api/rest/v1/people/update.", "errors": [ { "message": "updatePersonFields mask is required. Please specify one or more valid paths. Valid paths are documented at https://developers.google.com/people/api/rest/v1/people/update.", "domain": "global", "reason": "badRequest" } ], "status": "INVALID_ARGUMENT" }}'
Upvotes: 2
Views: 1191
Reputation: 1459
You need to specify the parameter updatePersonFields
. Seems like the parameters are passed as the last argument by looking at the read examples in the documentation. It probably should look something like:
$params = array('updatePersonFields' => 'names,emailAddresses');
$people_service->people->updateContact($google_id,$person,$params);
I haven't tested the above, so that might not be the exact syntax.
Upvotes: 2