“我的联系人"将Google通讯录分组 [英] "My Contacts" group google contacts

查看:157
本文介绍了“我的联系人"将Google通讯录分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚编写了一个小的python脚本,可将我的google联系人列表中的所有群组都显示给我,但是由于某种原因,我的联系人"未显示在其中.我正在使用3.0 API,并且在2.0 API中也遇到了类似的问题.以下是摘录自 Google 2.0联系人文档.

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.

例如,要确定我的联系人"组的ID,您可以检索给定用户的所有组的供稿,然后找到具有子元素的组条目,并获取该组条目的元素的值.

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.

当前我得到的响应在任何地方都没有gContact:systemGroup标记.如何获取特定组的组ID?

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?

我的脚本如下所示:-

user="blah@gmail.com"
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/blah@gmail.com/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.

推荐答案

为什么不使用 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('equinox@gmail.com', '**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...

然后从文档中获取

注意:提要可能不包含用户的所有联系人组,因为返回的结果数有默认限制.有关更多信息,请参见检索联系人组中的max-results查询参数使用查询参数.

注意:最新文档并排包含示例Python代码和协议说明; Python代码可帮助我将通用协议全神贯注.

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.

这篇关于“我的联系人"将Google通讯录分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆