3

我正在尝试通过 python 使用联系人 api,以便将联系人添加到 Gmail 中的组。这是我的小组用这个检索

Atom Id: http://www.google.com/m8/feeds/groups/user%40gmail.com/base/6d1fccc00a474e6c
Group Name: Newsletter
Last Updated: 2012-04-17T14:04:51.565Z
Extended Properties: Self
Link: https://www.google.com/m8/feeds/groups/user%40gmail.com/full/6d1fccc00a474e6c
Edit Link: https://www.google.com/m8/feeds/groups/user%40gmail.com/full/6d1fccc00a474e6c
ETag: "QHs9fTVSLit7I2A9WhVXFkoLQw0."

所以我正在尝试使用此代码来更改组成员身份

def add_group_membership(gd_client, contact_url, group_atom_id):
  contact = gd_client.GetContact(contact_url)
  contact.group_membership_info.append(gdata.contacts.data.GroupMembershipInfo(href=group_atom_id))
  try:
    updated_contact = gd_client.Update(contact)
    return updated_contact
  except gdata.client.RequestError, e:
    if e.status == 412:
      # Etags mismatch: handle the exception.
      pass
  return None

add_group_membership(gd_client, contact_url, 'http://www.google.com/m8/feeds/groups/user%40gmail.com/base/6d1fccc00a474e6c')

回应

gdata.client.RequestError: Server responded with: 404, Group not found.

我的联系人 = gd_client.GetContact(contact_url) 是对的

<ns0:entry xmlns:ns0="http://www.w3.org/2005/Atom" xmlns:ns1="http://schemas.google.com/g/2005" xmlns:ns2="http://www.w3.org/2007/app" ns1:etag="&quot;Rn04fTVSLyt7I2A9WhJQEkQKRwI.&quot;">[...]<ns2:edited>2012-07-26T08:07:47.335Z</ns2:edited></ns0:entry>

怎么了?

4

0 回答 0