“我的联系人”群组 Google 联系人

发布于 2024-12-06 23:40:45 字数 1305 浏览 0 评论 0原文

我刚刚编写了一个小的 python 脚本,它可以获取我的 google 联系人列表中的所有组,但是由于某种原因,“我的联系人”没有显示在其中。我正在使用 3.0 api,并且 2.0 api 也遇到类似的问题。以下内容摘自 Google 2.0 通讯录文档

例如,要确定“我的联系人”组的 ID,您可以检索给定用户的所有组的 Feed,然后查找具有子元素的组条目,并获取该组条目的元素的值。

目前,我收到的响应在任何地方都没有 gContact:systemGroup 标记。我应该如何获取特定组的组 ID?

我的脚本如下所示:-

user="[email protected]"
pas="blah"
data={"Email":user, "Passwd":pas, "service": "cp", "source":"tester"}
import urllib
data = urllib.urlencode(data)

import urllib2
req = urllib2.Request('https://www.google.com/accounts/ClientLogin', data)
resp = urllib2.urlopen(req)
x = resp.read()

auth=a[-1].split('=')[-1]
req = urllib2.Request('https://www.google.com/m8/feeds/groups/[email protected]/full/', headers={'Authorization':'GoogleLogin auth='+auth})
resp = urllib2.urlopen(req)
x = resp.read()
print x
print "My Contacts" in x
print "gContact:systemGroup" in x

关于如何解决此问题的一些线索将非常棒,谢谢。

I just wrote a small python script that gets me all the groups on my google contacts list, however for some reason "My Contacts" does not show up in that. I'm using the 3.0 api and was having similar problems with the 2.0 api too. The following is an except taken from the Google 2.0 Contacts documentation.

To determine the My Contacts group's ID, for example, you can retrieve a feed of all the groups for a given user, then find the group entry that has the subelement, and take the value of that group entry's element.

Currently the response that I get does not have a gContact:systemGroup tag anywhere. How should I proceed in order to get the group id of a particular group?

My script is as shown below:-

user="[email protected]"
pas="blah"
data={"Email":user, "Passwd":pas, "service": "cp", "source":"tester"}
import urllib
data = urllib.urlencode(data)

import urllib2
req = urllib2.Request('https://www.google.com/accounts/ClientLogin', data)
resp = urllib2.urlopen(req)
x = resp.read()

auth=a[-1].split('=')[-1]
req = urllib2.Request('https://www.google.com/m8/feeds/groups/[email protected]/full/', headers={'Authorization':'GoogleLogin auth='+auth})
resp = urllib2.urlopen(req)
x = resp.read()
print x
print "My Contacts" in x
print "gContact:systemGroup" in x

Some clues on how I could troubleshoot this would be awesome, thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半﹌身腐败 2024-12-13 23:40:45

为什么不使用 Python 客户端库直接?它包含一组方法,可以完全满足您的需求。

import gdata.contacts.client
import gdata.contacts.data # you might also need atom.data, gdata.data

gd_client = gdata.contacts.data.ContactsClient(source='eQuiNoX_Contacts')
gd_client.ClientLogin('[email protected]', '**password**')

feed = gd_client.GetGroups()
    for entry in feed.entry:
        print 'Atom Id: %s' % group.id.text
        print 'Group Name: %s' % group.title.text
        if not entry.system_group:
            print 'Edit Link: %s' % entry.GetEditLink().href
            print 'ETag: %s' % entry.etag
        else:
            print 'System Group Id: %s' % entry.system_group.id

这能解决您的问题吗?从某种程度上来说,它更干净。如果您仍然遇到问题:

...由于某种原因,“我的联系人”没有显示...

然后从文档中:

注意:提要可能不包含用户的所有联系人组,因为返回的结果数量有默认限制。有关详细信息,请参阅检索联系人群组中的最大结果查询参数使用查询参数

注意:较新的文档包括示例 Python 代码和协议解释; Python 代码帮助我理解通用协议。

Why not use the Python Client Library directly? It includes a set of methods that do exactly what you want.

import gdata.contacts.client
import gdata.contacts.data # you might also need atom.data, gdata.data

gd_client = gdata.contacts.data.ContactsClient(source='eQuiNoX_Contacts')
gd_client.ClientLogin('[email protected]', '**password**')

feed = gd_client.GetGroups()
    for entry in feed.entry:
        print 'Atom Id: %s' % group.id.text
        print 'Group Name: %s' % group.title.text
        if not entry.system_group:
            print 'Edit Link: %s' % entry.GetEditLink().href
            print 'ETag: %s' % entry.etag
        else:
            print 'System Group Id: %s' % entry.system_group.id

Does this solve your problem? It's cleaner, in a way. If you're still having trouble with:

...for some reason "My Contacts" does not show up...

then from the documentation:

Note: The feed may not contain all of the user's contact groups, because there's a default limit on the number of results returned. For more information, see the max-results query parameter in Retrieving contact groups using query parameters.

Note: The newer documentation includes sample Python code side-by-side with the protocol explanation; the Python code helps me wrap my head around the generic protocol.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文