- I am using Google API PHP Client Library v2.1.3
- I am following the documentation for Domain Shared Contacts
- I am following the batch processing guidelines for delete
Here is the logic I'm using:
$xmlBuild = "<feed xmlns='http://www.w3.org/2005/Atom'
xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'
xmlns:batch='http://schemas.google.com/gdata/batch'
xmlns:gd='http://schemas.google.com/g/2005'
xmlns:gContact='http://schemas.google.com/contact/2008'>";
$xmlBuild .= "<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'>";
$xmlBuild .= "<batch:id>1</batch:id><batch:operation type='delete'/>";
$xmlBuild .= "<id>http://www.google.com/m8/feeds/contacts/my.domain/base/1b93ef80b806243</id>";
$xmlBuild .= "<link rel='edit' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/my.domain/full/1b93ef80b806243/1812952240373020'/>";
$xmlBuild .= "</entry>";
$xmlBuild .= "</feed>";
$len = strlen($xmlBuild);
$options = array(
"headers" => array(
"Content-type" => "application/atom+xml; charset=UTF-8;",
"Content-lenght" => $len
),
"body" => $xmlBuild
);
$httpClient = $client->authorize();
$request = $httpClient->delete("https://www.google.com/m8/feeds/contacts/my.domain/full/batch", $options);
$response = $request->getBody()->getContents();
print_r($response); //This prints "Contact ID not found."
// ??? why ???
I'm pretty sure I am doing everything correct. To me,it seems a buggy behavior. I already searched for any example that shows how to do this to no avail. Is anyone here capable of determining if there is something wrong with my logic? Thanks in advance for any help that can be provided.
P.D. The insert method works like a charm. The problem is only with deleting the contacts. I haven't tested the update method yet but it all points out to be almost the same as the delete. There is no problem in doing the deletion without batching.