Gmail 通訊錄同步於asterisk

Gmail 通訊錄同步於asterisk

GMail ??????Asterisk ? gmail ??????? Asterisk CID ?????? googlecontacts.py #!/usr/bin/python # googlecontacts.py v0.1 # By: John Baab # Email: [email protected] # MODIFIED by : Raphael # Purpose: syncs contacts from google to asterisk server # Requirements: python, gdata python client, asterisk # # License: # # This Package is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public # License as published by the Free Software Foundation; either # version 3 of the License, or (at your option) any later version. # # This package is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public # License along with this package; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # On Debian & Ubuntu systems, a complete copy of the GPL can be found under # /usr/share/common-licenses/GPL-3, or (at your option) any later version import atom,re,sys,os import gdata.contacts import gdata.contacts.service def main(): gd_client = gdata.contacts.service.ContactsService() gd_client.email = "[email protected]" gd_client.password = "PASSWORD" gd_client.source = 'gcontact2ast' gd_client.ProgrammaticLogin() query = gdata.contacts.service.ContactsQuery() query.max_results = 1000 feed = gd_client.GetContactsFeed(query.ToUri()) # delete all of our contacts before we refetch them, this will allow deletions os.system("asterisk -rx \'database deltree cidname\'") 1 GMail ??????Asterisk # for each phone number in the contacts for i, entry in enumerate(feed.entry): for phone in entry.phone_number: # Strip out any non numeric characters phone.text = re.sub('\D', '', phone.text) # Insert the number into the cidname database, reinsert the 00 (international)code. os.system("asterisk -rx \'database put cidname 00%s \"%s\"\'" % (phone.text,entry.title.text)) if __name__ == "__main__": main() 2.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    2 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us