Google通讯录Api - >删除了哪些联系人?

时间:2022-08-28 15:26:30

I am parsing contacts from Gmail, and creating a sync functionality with my product. But on my script i'm having a hard time determining which contacts get 'deleted' from gmail.

我正在解析Gmail中的联系人,并在我的产品中创建同步功能。但在我的脚本上,我很难确定哪些联系人从gmail中被“删除”。

EXAMPLE: If I have John Doe in my Application, along with Gmail... (and they are synced with the gmailId). Later on down the road, if the user DELETES the contact John Doe, and I run my SYNC, how do I determine that the contact was deleted?

示例:如果我的应用程序中包含John Doe,以及Gmail ...(并且它们与gmailId同步)。稍后,如果用户删除联系人John Doe,并运行我的SYNC,如何确定联系人已被删除?

I need to know where to throw a trigger to delete the same contact within my database. I currently have this to obtain information on each contact sent through.

我需要知道在哪里抛出触发器来删除我的数据库中的同一个联系人。我目前有这个来获取通过发送的每个联系人的信息。

$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'm also query google with these extra params.

以前在我的代码中我也用这些额外的参数查询谷歌。

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

Any help would be appreciated!

任何帮助,将不胜感激!

2 个解决方案

#1


1  

I'm not sure about any particular hooks, nor can I see an obvious deleted field, but here is another way to solve the problem...

我不确定任何特定的钩子,也不能看到明显的删除字段,但这是另一种解决问题的方法......

When you do your full sync, or single item updates, if a particular contact is no longer returned, then you can mark it as deleted. Note, this would only work if you keep showdeleted as false.

当您执行完全同步或单项更新时,如果不再返回特定联系人,则可以将其标记为已删除。请注意,这仅在您将showdeleted保持为false时才有效。

Example...

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

You run a full sync...

你运行完全同步...

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

Comparing the two arrays will show that 7 has been deleted. Similarly, if you are synchronizing a single item, if it doesn't return anything you can assume its deleted.

比较两个数组将显示已删除7。同样,如果您正在同步单个项目,如果它没有返回任何内容,您可以认为它已被删除。

#2


1  

I found out that Google adds an empty XML Tag called Deleted when a contact is deleted.

我发现当删除联系人时,Google会添加一个名为Deleted的空XML标记。

Something like this.

像这样的东西。

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

Although Adrian's solution would work, I felt that wasn't the best solution as I felt Google must to have an answer for this rather than checking to see if a contact was available every day.

虽然Adrian的解决方案可行,但我认为这不是最佳解决方案,因为我认为Google必须为此提供答案,而不是检查每天是否有联系人。

#1


1  

I'm not sure about any particular hooks, nor can I see an obvious deleted field, but here is another way to solve the problem...

我不确定任何特定的钩子,也不能看到明显的删除字段,但这是另一种解决问题的方法......

When you do your full sync, or single item updates, if a particular contact is no longer returned, then you can mark it as deleted. Note, this would only work if you keep showdeleted as false.

当您执行完全同步或单项更新时,如果不再返回特定联系人,则可以将其标记为已删除。请注意,这仅在您将showdeleted保持为false时才有效。

Example...

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

You run a full sync...

你运行完全同步...

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

Comparing the two arrays will show that 7 has been deleted. Similarly, if you are synchronizing a single item, if it doesn't return anything you can assume its deleted.

比较两个数组将显示已删除7。同样,如果您正在同步单个项目,如果它没有返回任何内容,您可以认为它已被删除。

#2


1  

I found out that Google adds an empty XML Tag called Deleted when a contact is deleted.

我发现当删除联系人时,Google会添加一个名为Deleted的空XML标记。

Something like this.

像这样的东西。

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

Although Adrian's solution would work, I felt that wasn't the best solution as I felt Google must to have an answer for this rather than checking to see if a contact was available every day.

虽然Adrian的解决方案可行,但我认为这不是最佳解决方案,因为我认为Google必须为此提供答案,而不是检查每天是否有联系人。