1

I want to delete a list of contact with Google API feeds.

I generate the following XML body :

<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:gContact="http://schemas.google.com/contact/2008" xmlns:gd="http://schemas.google.com/g/2005" xmlns:batch="http://schemas.google.com/gdata/batch">
  <entry>
    <batch:id>delete</batch:id>
    <batch:operation type="delete"/>
    <id>http://www.google.com/m8/feeds/contacts/<email>/base/c001f30f8a96bd</id>
  </entry>
  <entry>
    <batch:id>delete</batch:id>
    <batch:operation type="delete"/>
    <id>http://www.google.com/m8/feeds/contacts/<email>/base/13112ef0ace9063</id>
  </entry>
</feed>

after that, I'm calling a Google_Http_Request

$req = new \Google_Http_Request('https://www.google.com/m8/feeds/contacts/default/full/batch/');
$req->setRequestHeaders(array('content-type' => 'application/atom+xml; charset=UTF-8; type=feed'));
$req->setRequestMethod('DELETE');
$req->setPostBody($myXML);

Google send me an error 500.

I don't know where my problem is. Someone have an idea ?

Many thanks,

jeremy.romano
  • 141
  • 2
  • 8
  • I had a similar problem a while ago.. maybe this can help https://stackoverflow.com/questions/47764210/batch-delete-domain-shared-contacts-with-php – Morfinismo May 24 '18 at 00:51

1 Answers1

0

I solved the problem, thanks to @Morfinismo.

  • I changed the method 'DELETE' to 'POST'
  • I added 'If-Match: *' in the header request
  • I replaced the 'id' by 'editURL'

That's it.

jeremy.romano
  • 141
  • 2
  • 8