I am trying to modify a contact but doesn't work. The $idg
value contain the contact info in the way: ht*t*p://www.google.com/m8/feeds/contacts/xxxxx%40gmail.com/base/yyyyyyyyyyyy
To include a new contact is working calling: h*t*tp://www.google.com/m8/feeds/contacts/xxxxx%40gmail.com/full
and using a $add->setRequestMethod("POST");
but I am not able to modify a contact.
session_start();
$user_email = 'xxxxx%40gmail.com';
$client = new Google_Client();
$client->setApplicationName("Google Apps PHP Starter Application");
$client->setScopes(array(
'https://www.google.com/m8/feeds/',
'https://www.google.com/m8/feeds/user/',
));
$client->setApplicationName('Pepe');
$client->setClientId('jjjjjj.apps.googleusercontent.com');
$client->setClientSecret('jjjjjjjj');
$client->setRedirectUri('urn:ietf:wg:oauth:2.0:oob');
$client->setAccessToken(file_get_contents('refreshtoken.conf'));
$contact="
<atom:entry xmlns:atom='http://www.w3.org/2005/Atom'
xmlns:gd='http://schemas.google.com/g/2005'
xmlns:gContact='http://schemas.google.com/contact/2008'>
<atom:category scheme='http://schemas.google.com/g/2005#kind'
term='http://schemas.google.com/contact/2008#contact'/>
<gd:name>
<gd:givenName>".utf8_decode($nom)."</gd:givenName>
<gd:familyName>".utf8_decode($ape)."</gd:familyName>
<gd:fullName>".utf8_decode($nom)." ".utf8_decode($ape)."</gd:fullName>
</gd:name>
<atom:content type='text'>Notes</atom:content>
<gd:email rel='http://schemas.google.com/g/2005#home'
primary='true'
address='".$ema."' displayName='".utf8_decode($nom)." ".utf8_decode($ape)."'/>
<gd:phoneNumber rel='http://schemas.google.com/g/2005#mobile'
primary='true'>
".$tel."
</gd:phoneNumber>
<gd:structuredPostalAddress
rel='http://schemas.google.com/g/2005#home'
primary='true'>
<gd:city>".$ciu."</gd:city>
<gd:street>".$dir." ".$num." ".$pue."</gd:street>
<gd:region></gd:region>
<gd:postcode></gd:postcode>
<gd:country>Spain</gd:country>
<gd:formattedAddress>
".$dir." ".$num." ".$pue." ".$ciu."
</gd:formattedAddress>
</gd:structuredPostalAddress>
<gContact:userDefinedField key='Codigo' value='".$cod."'/>
<gContact:userDefinedField key='Doctor' value='".$doct."'/>
<gContact:userDefinedField key='Especialista' value='".$espe."'/>
<gContact:groupMembershipInfo deleted='false'
href='http://www.google.com/m8/feeds/groups/".$user_email."/base/6'/>
<gContact:groupMembershipInfo deleted='false'
href='http://www.google.com/m8/feeds/groups/".$user_email."/base/3adf49fe0beabbb2'/>
</atom:entry>
";
$len = strlen($contact);
$add = new Google_Http_Request("".$idg."");
$add->setRequestMethod("PUT");
$add->setPostBody($contact);
$add->setRequestHeaders(array('content-length' => $len, 'GData-Version'=> '3.0','content-type'=>'application/atom+xml; charset=UTF-8; type=feed'));
$submit = $client->getAuth()->authenticatedRequest($add);
$sub_response = $submit->getResponseBody();
$parsed = simplexml_load_string($sub_response);
$client_id = explode("base/",$parsed->id);
$idgoogle = $parsed->id;
echo 'The ID of the new entry is: ' . $parsed->id;
echo 'Por ahora es '. $submit;
echo 'Entry updated';
} catch (Exception $e) {
die('ERROR:' . $e->getMessage());
}
}