我正在Google App Engine上编写一个小应用程序,以更新用户个人资料中的图片。它需要那里的用户名和图像,并把它放到那里配置文件,上传图像。这里是我有:如果这是因为我传递的个人资料网址了作为一个字符串或上传更新个人档案图片Google Apps/Google App Engine
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\webapp\_webapp25.py", line 703, in __call__
handler.post(*groups)
File "C:\GAE_Local_Files\picupload\sasakipic.py", line 40, in post
profile = gd_client.GetProfile(profile_url)
File "C:\GAE_Local_Files\picupload\gdata\contacts\client.py", line 375, in get_profile
auth_token=auth_token, **kwargs)
File "C:\GAE_Local_Files\picupload\gdata\client.py", line 652, in get_entry
desired_class=desired_class, **kwargs)
File "C:\GAE_Local_Files\picupload\gdata\client.py", line 278, in request
version=get_xml_version(self.api_version))
File "C:\GAE_Local_Files\picupload\atom\core.py", line 520, in parse
tree = ElementTree.fromstring(xml_string)
File "<string>", line 106, in XML
ParseError: not well-formed (invalid token): line 1, column 0
我不知道:
import atom.data
import gdata.data
import gdata.contacts.client
import gdata.contacts.data
import cgi
import wsgiref.handlers
from google.appengine.api import users
from google.appengine.ext import webapp
email = '[email protected]'
password = 'password'
domain = 'domain.com'
gd_client = gdata.contacts.client.ContactsClient(domain=domain)
gd_client.ClientLogin(email, password, 'photoUpdate')
class PicPage(webapp.RequestHandler):
def get(self):
self.response.out.write("""<html><head><title>Sasaki Photo Uploader</title>
<link type="text/css" rel="stylesheet" href="/stylesheets/form.css"></head>
<body>
<form action="/" enctype="multipart/form-data" method="post">
<div><label>Person Name</label></div>
<div><textarea name="name" rows="2" columns "60"></textarea></div>
<div><label>Image</label></div>
<div><input type="file" name="img"/></div>
<div><input type="submit" value="Upload" /></div>
</form>
</body>
</html>""")
def post(self):
person_name = self.request.get('name')
img_img = self.request.get('img')
profile_url = 'https://www.google.com/m8/feeds/photos/profile/domain.com/%s' % person_name
media_object = img_img
print(profile_url)
profile = gd_client.GetProfile(profile_url)
print(profile)
gd_client.ChangePhoto(media_object, profile)
self.redirect('/')
def main():
application = webapp.WSGIApplication(
[('/', PicPage)
],
debug=True)
wsgiref.handlers.CGIHandler().run(application)
if __name__=="__main__":
main()
当我运行这个它返回错误图错了。任何建议,非常感谢。
编辑添加完整的堆栈跟踪
什么是错误的完整调用堆栈?我怀疑你需要在调用gd_client.ChangePhoto时使用MediaSource对象。 – 2012-01-31 16:33:46
您可以在picupload \ atom \ core.py:520中放置断点(或打印语句)以检查xml_string的值 – proppy 2012-02-08 13:19:57