def callBack(fromPhone,to,customerSerNum,fromSerNum,promptTone,userData,maxCallTime,hangupCdrUrl): if str(fromPhone).startswith('12') or str(fromPhone).startswith('11'): return if str(to).startswith('12') or str(to).startswith('11'): return #初始化REST SDK rest = REST(serverIP,serverPort,softVersion) rest.setSubAccount(subAccountSid,subAccountToken,voIPAccount,voIPPassword) rest.setAppId(appId) try: result = rest.callBack(fromPhone,to,customerSerNum,fromSerNum,promptTone,userData,maxCallTime,hangupCdrUrl) for k,v in result.iteritems(): if k=='CallBack' : for k,s in v.iteritems(): print '%s:%s' % (k, s) else: print '%s:%s' % (k, v) except Exception,e: pass