Search code examples
phpgoogle-contacts-apigoogle-shared-contacts

Google Contacts API - Delete Contact (400 Error)


I have been able to successfully, Add, Modify, but cannot delete a contact. This is my request, but I continue to receive this error, and i'm not sure the issue, it has to be with my 'content', but i'm not sure what is missing. Any light shed upon this would be greatly appreciated!

URL REQUEST:
https://www.google.com/m8/feeds/contacts/{userEmail}/full/{contactId}

METHOD: DELETE
XML CONTENT:
<entry etag='*'><id>https://www.google.com/m8/feeds/contacts/{userEmail}/full/54934b770f18de29</id>
</entry>

ERROR: 400 That's an error. Your client has issued a malformed or illegal request. That's all we know.

NOTE: I am trying out, Manuel Lemos Class: http://www.phpclasses.org/package/7700-PHP-Authorize-and-access-APIs-using-OAuth.html


Solution

  • I received an answer from Manuel on his forum.

    Here is the response.

    api_url = 'https://www.googleapis.com/some-google-api-url';
    $options = array(
    'RequestHeaders'=>array(
    'If-Match'=>'if match value here', 
    'FailOnAccessError'=>true
    );
    $success = $client->CallAPI($api_url, 'DELETE', array(), $options, $results);