“我的联系人”群组 Google 联系人
我刚刚编写了一个小的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不使用 Python 客户端库直接?它包含一组方法,可以完全满足您的需求。
这能解决您的问题吗?从某种程度上来说,它更干净。如果您仍然遇到问题:
然后从文档中:
注意:较新的文档包括示例 Python 代码和协议解释; Python 代码帮助我理解通用协议。
Why not use the Python Client Library directly? It includes a set of methods that do exactly what you want.
Does this solve your problem? It's cleaner, in a way. If you're still having trouble with:
then from the documentation:
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.