我无法访问某些 GData 联系人属性,例如性别

发布于 2024-10-02 12:56:22 字数 2146 浏览 7 评论 0原文

这是代码:

def fetch_feed(self):
        client = gdata.contacts.service.ContactsService()
        client.ClientLogin(username, password) #Will change to AuthSub later.
        query = gdata.contacts.service.ContactsQuery()
        query.max_results = 3000
        feed = client.GetContactsFeed(query.ToUri())
        memcache.set('feed',feed, 3600)
        return feed

feed = self.fetch_feed()
self.PrintFeed(feed)

def PrintFeed(self, feed):
        for entry in feed.entry:
            print entry.* #example... i can access properties such as entry.title, entry.id, entry.updated, but can't access a whole lot more.

我做错了什么,或者我根本没有做什么? 我在 Apps API 论坛上发布了同样的问题,只是为了澄清一些事情。

编辑 这是我要导入的内容:

from google.appengine.api import memcache, users
from google.appengine.ext import db, webapp
from google.appengine.ext.webapp import util
import atom
import atom.url
import datetime
import gdata.alt.appengine

import gdata.contacts
import gdata.contacts.client
import gdata.contacts.data
import gdata.contacts.service
import gdata.client
import gdata.service
import settings

EDIT2: 修复 qry 拼写错误后出现的错误:

Traceback (most recent call last):
  File "C:\Program Files\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 511, in __call__
    handler.get(*groups)
  File "C:\etrebug\main.py", line 55, in get
    feed = self.fetch_feed()
  File "C:\etrebug\main.py", line 67, in fetch_feed
    feed = client.get_contacts(qry)
  File "C:\etrebug\gdata\contacts\client.py", line 194, in get_contacts
    desired_class=desired_class, **kwargs)
  File "C:\etrebug\gdata\client.py", line 635, in get_feed
    **kwargs)
  File "C:\etrebug\gdata\client.py", line 276, in request
    version=get_xml_version(self.api_version))
  File "C:\etrebug\atom\core.py", line 516, in parse
    return _xml_element_from_tree(tree, target_class, version)
  File "C:\etrebug\atom\core.py", line 525, in _xml_element_from_tree
    if target_class._qname is None:
AttributeError: 'ContactsQuery' object has no attribute '_qname'

Here's the code:

def fetch_feed(self):
        client = gdata.contacts.service.ContactsService()
        client.ClientLogin(username, password) #Will change to AuthSub later.
        query = gdata.contacts.service.ContactsQuery()
        query.max_results = 3000
        feed = client.GetContactsFeed(query.ToUri())
        memcache.set('feed',feed, 3600)
        return feed

feed = self.fetch_feed()
self.PrintFeed(feed)

def PrintFeed(self, feed):
        for entry in feed.entry:
            print entry.* #example... i can access properties such as entry.title, entry.id, entry.updated, but can't access a whole lot more.

What am i doing wrong, or what am i not doing at all?
I posted the same question on the Apps API forum, just to clarify things.

EDIT
Here's what i'm importing:

from google.appengine.api import memcache, users
from google.appengine.ext import db, webapp
from google.appengine.ext.webapp import util
import atom
import atom.url
import datetime
import gdata.alt.appengine

import gdata.contacts
import gdata.contacts.client
import gdata.contacts.data
import gdata.contacts.service
import gdata.client
import gdata.service
import settings

EDIT2:
The error i got after fixing the qry typo:

Traceback (most recent call last):
  File "C:\Program Files\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 511, in __call__
    handler.get(*groups)
  File "C:\etrebug\main.py", line 55, in get
    feed = self.fetch_feed()
  File "C:\etrebug\main.py", line 67, in fetch_feed
    feed = client.get_contacts(qry)
  File "C:\etrebug\gdata\contacts\client.py", line 194, in get_contacts
    desired_class=desired_class, **kwargs)
  File "C:\etrebug\gdata\client.py", line 635, in get_feed
    **kwargs)
  File "C:\etrebug\gdata\client.py", line 276, in request
    version=get_xml_version(self.api_version))
  File "C:\etrebug\atom\core.py", line 516, in parse
    return _xml_element_from_tree(tree, target_class, version)
  File "C:\etrebug\atom\core.py", line 525, in _xml_element_from_tree
    if target_class._qname is None:
AttributeError: 'ContactsQuery' object has no attribute '_qname'

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

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

发布评论

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

评论(1

離殇 2024-10-09 12:56:22

你可以试试V3客户端

client = gdata.contacts.client.ContactsClient()
client.client_login(usr, passwd, "myscript")
qry = gdata.contacts.client.ContactsQuery(max_results=3000)
feed = client.get_contacts(query=qry)

for entry in feed.entry:
    # do something with entry

You can try the V3 client

client = gdata.contacts.client.ContactsClient()
client.client_login(usr, passwd, "myscript")
qry = gdata.contacts.client.ContactsQuery(max_results=3000)
feed = client.get_contacts(query=qry)

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