def sms_send(user, password, api_id, text, to): import urllib url = "http://api.urlsms.com/SendSMS.aspx" #url = "http://196.7.150.220/http/sendmsg" params = urllib.urlencode({'UserID': user, 'Password': password, 'SenderID': api_id, 'MsgText': text, 'RecipientMobileNo':to}) f = urllib.urlopen(url+"?"+params) # FIXME: Use the logger if there is an error return True
def sms_send(user, password, api_id, text, to): import urllib url = "http://www.msc8.cn/cgi/sendsmsbatch.asp" #url = "http://196.7.150.220/http/sendmsg" params = urllib.urlencode({'User': user, 'Pass': password, 'Mobile': to, 'Text': text}) f = urllib.urlopen(url+"?"+params) import re p=re.compile('^200 ') if p.match(res): #send OK! netsvc.Logger().notifyChannel('SMS_send', netsvc.netsvc.LOG_DEBUG, f.read()) else: netsvc.Logger().notifyChannel('SMS_send', netsvc.netsvc.LOG_ERROR, f.read()) # FIXME: Use the logger if there is an error return True
青島維泰的接口中,可以用逗號隔開,輸入多個手機號碼。上述代碼中,增加了一段檢查短信發送是否成功的代碼,發送成功應該返回“200 ”開頭的一段文字,如果發送失敗,將在OpenERP的Log中記錄錯誤信息。
另外,為了處理漢字(gb2312),server\addons\base\res\partner\wizard\wizard_sms.py下的方法_sms_send 也要修改一下。
原 文:tools.sms_send(data['form']['user'], data['form']['password'], data['form']['app_id'], unicode(data['form']['text'], 'utf-8').encode('latin1'), to)
改成:tools.sms_send(data['form'] ['user'], data['form']['password'], data['form']['app_id'], unicode(data['form']['text'], 'utf-8').encode('gb2312'), to
轉自;http://blog.sina.com.cn/s/blog_ade196920101dz1a.html
*