Google Contacts Api & # 8594; What contacts have been deleted?

I am sorting contacts from Gmail and creating synchronization with my product. But in my script, it's hard for me to determine which contacts will be deleted from gmail.

Example: If I have John Doe in my application, along with Gmail ... (and they synchronize with gmailId). Later in the future, if a user DELETES a John Doe contact and I started my SYNC , how can I determine that the contact has been deleted?

I need to know where to drop the trigger in order to delete the same contact in my database. Currently, I have this to get information about each contact I sent.

$xml = simplexml_load_string($entry->getXML()); $obj = new stdClass; // EDIT LINK $obj->gmailUrl = rawurlencode($entry->id); $obj->delete = (string) $xml->groupMembershipInfo['deleted']; // FIRST Name $obj->firstName = (string) $xml->name->givenName; 

Previous in my code, I also request google with these additional parameters.

 $query->setParam('updated-min', $updatedMin); $query->setParam('showdeleted', 'true'); $query->setParam('requirealldeleted', 'true'); 

Any help would be appreciated!

+4
source share
2 answers

I found out that Google adds an empty XML tag called "Deleted" when the contact is deleted.

Something like that.

 if(isset($xml->deleted)) { $deleted = "true"; } else { $deleted = NULL; } $obj->delete = $deleted; 

Despite the fact that the Adrian solution will work, I felt that this is not the best solution, since I believe that Google should have an answer for this, and not check whether the contact is available every day.

+1
source

I'm not sure about any specific hooks and don't see the explicit deleted field, but here is another way to solve the problem ...

When you perform full synchronization or updates of individual items, if a specific contact no longer returns, you can mark it as deleted. Note that this will only work if you keep showdeleted as false .

Example...

 $local = array(1, 3, 5, 7, 9); 

You start full synchronization ...

 $remote = array(, 1, 3, 5, 9); 

A comparison of the two arrays will show that 7 is deleted. Similarly, if you synchronize one item, if it does not return anything, you can consider it deleted.

+1
source

All Articles