import gdata.contacts.service import atom import gdata.contacts import getpass client = gdata.contacts.service.ContactsService() client.email = raw_input('Please enter your email address') client.password = getpass.getpass() client.source = 'Google-ContactsGetTest-1.0' client.ProgrammaticLogin() name = 'Fred' notes = 'Test entry' primary_email = 'test2903488769871632@example.com' new_contact = gdata.contacts.ContactEntry(title=atom.Title(text=name)) new_contact.content = atom.Content(text=notes) new_contact.email.append(gdata.contacts.Email(address=primary_email, primary='true', rel=gdata.contacts.REL_WORK)) new_contact.phone_number.append(gdata.contacts.PhoneNumber( rel=gdata.contacts.REL_OTHER, text='555-1212-3242')) entry = client.CreateContact(new_contact) if entry: print 'Creation successful!' print 'Edit link for the new contact:', entry.GetEditLink().href else: print 'Upload error.' # Remove the phone number del entry.phone_number[0] updated = client.UpdateContact(entry.GetEditLink().href, entry) if updated: print 'Update successful!' print 'Edit link for the updated contact:', updated.GetEditLink().href else: print 'Upload error.' raw_input('enter to delete') client.Delete(updated.GetEditLink().href)
Edit contact phone numbers using Python
Posted by
Jeff Scudder
on
Monday, August 04, 2008
This sample shows the creation of a contact using the Google Contacts API. The phone number for the contact is then removed by editing the local contact entry object and uploading. At the ned, the script asks you to press enter before deleting the test contact.
Subscribe to:
Post Comments (Atom)
3 comments:
hi i used this code and it was very helpful for me, but i want to add a contact number to "My Contact" System Group in google contcts. pls what we have to do with this existing code.
thank you
Dịch vụ kế toán ACB chuyên cung cấp Dich vu ke toan trọn gói uy tín chuyên nghiêp giá rẻ nhất tại HCM và các tỉnh lân cận với chi phí bỏ ra từ 500.000-1.500.000đ.
Liên hệ: Dịch vụ kế toán , Dich vu ke toan.
Lầu 4, Tòa nhà Long Mã, 602 Cộng Hòa,P.13,Q.Tân Bình,HCM.
Hotline: (08) 62 97 97 97 - 0966 660 888.
I read your article, Thanks for sharing this information.
https://www.sevenmentor.com/best-python-classes-in-pune.php
Post a Comment