After creating the batch XML I used the following snippet, which is working really well:
$headers = array( 'Host: www.google.com', 'Content-length: '.strlen($contactXML), 'Content-type: application/atom+xml', 'Authorization: OAuth '.$integration['AuthToken'], ); $contactQuery = 'https://www.google.com/m8/feeds/contacts/default/full/batch?v=3.0'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $contactQuery ); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $contactXML); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_FAILONERROR, true); $response = curl_exec($ch); if($response === false) { $content .= 'cURL Operation Failed ('.curl_error($ch).')<br />'; } else { $content .= 'cURL Operation Successful<br />'; } curl_close($ch); On Wednesday, 15 August 2012 10:48:30 UTC+1, peteyg wrote: > > I was wondering if anyone is aware of any code examples for *updating* Google > Contacts data in PHP. I have no problems authenticating and retrieving > contacts using Google's provided API ( > http://code.google.com/p/google-api-php-client/wiki/OAuth2) > > However, this does not appear to have any support for manipulating the > contacts. I have also tried Zend Gdata ( > http://framework.zend.com/download/gdata/) to achieve this, but this > works off oAuth 1.0. Which is not only deprecated, but I cannot verify my > URLs (as they are on an intranet). > > The guide (https://developers.google.com/google-apps/contacts/v3/) is > useful, but has no specific PHP examples. The main problem I'm having > revolves around trying to send authenticated cURL requests.. This guide ( > https://developers.google.com/gdata/articles/using_cURL#updating-entries) > has been useful but still I have found no solution so far. > > Any help or suggestions would be greatly appreciated! > -- You received this message because you are subscribed to the Google Groups "Google Contacts, Shared Contacts and User Profiles APIs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://code.google.com/apis/contacts/community/forum.html
