Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate Profile Picture Google Apps / Google App Engine
    primarykey
    data
    text
    <p>I am writing a small app on Google App Engine to update the pictures in our users profiles. It takes there username and an image and does a put to there profile, uploading the image. Here is what i have:</p> <pre><code>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 = 'admin@domain.com' 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("""&lt;html&gt;&lt;head&gt;&lt;title&gt;Sasaki Photo Uploader&lt;/title&gt; &lt;link type="text/css" rel="stylesheet" href="/stylesheets/form.css"&gt;&lt;/head&gt; &lt;body&gt; &lt;form action="/" enctype="multipart/form-data" method="post"&gt; &lt;div&gt;&lt;label&gt;Person Name&lt;/label&gt;&lt;/div&gt; &lt;div&gt;&lt;textarea name="name" rows="2" columns "60"&gt;&lt;/textarea&gt;&lt;/div&gt; &lt;div&gt;&lt;label&gt;Image&lt;/label&gt;&lt;/div&gt; &lt;div&gt;&lt;input type="file" name="img"/&gt;&lt;/div&gt; &lt;div&gt;&lt;input type="submit" value="Upload" /&gt;&lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;""") 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() </code></pre> <p>When I run this it returns the error:</p> <pre><code> 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 "&lt;string&gt;", line 106, in XML ParseError: not well-formed (invalid token): line 1, column 0 </code></pre> <p>i am not sure if this is because I am passing the profile url off as a string or uploading the pic wrong. Any advice, much appreciated. </p> <p><strong>EDIT</strong> Added full stack trace</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload