Google通讯录v3 API +如何向群组添加联系人?

时间:2014-01-08 20:38:46

标签: google-contacts

我可以与联系人或群组进行CRUD,但我无法弄清楚如何将联系人添加到特定群组。

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

 def get_group_id(label_name):
    feed = gd_client.GetGroups()
    for entry in feed.entry:
        if entry.title.text.lower() == label_name:
            return entry.id.text


contact_entry = gdata.contacts.data.ContactEntry() #contact_entry
group = get_group_id(label_name) #group id
membership = gdata.contacts.data.GroupMembershipInfo(href=group) #group membership
contact_entry.group_membership_info.append(membership) # adding group membership to contact_entry