I am trying to add photo to google contact, using python and gdata library.
contact = gd_client.GetContact('http://www.google.com/m8/feeds/contacts/denisz.pol%40gmail.com/base/61839cbb8a335dbb')
gd_client.ChangePhoto('img.jpeg',contact)
But there is an error:
AttributeError Traceback (most recent call last)
<ipython-input-62-03d065010e8f> in <module>()
----> 1 gd_client.ChangePhoto('img.jpeg',contact)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gdata/contacts/client.py in change_photo(self, media, contact_entry_or_url, content_type, content_length, auth_token, **kwargs)
253 ifmatch_header = None
254 if isinstance(contact_entry_or_url, gdata.contacts.data.ContactEntry):
--> 255 photo_link = contact_entry_or_url.GetPhotoLink()
256 uri = photo_link.href
257 ifmatch_header = atom.client.CustomHeaders(
AttributeError: 'NoneType' object has no attribute 'href'
If I add photo to contact "by hands" nothing will change.
What am I doing wrong?
It is, strange but if we call GetPhotLink()
outside the ChangePhoto
function href
attribute will not be None
. So this code
gd_client.ChangePhoto('img.jpeg',contact.GetPhotoLink().href, content_type='image/*')
will change the photo.