我正在尝试按照Python suds程序发送短信,但遇到了一些与urllib2相关的问题
当我尝试执行代码时,API URL,用户名和由移动服务公司提供,但我收到与### urllib2.URLError ###
相关的错误from suds.client import Client
client = Client(url='https://cbs.zong.com.pk/reachcwsv2 /corporatesms.svc?wsdl',
username='9231089894269149',
password='Zo98989ng@123', cache=None)
obj_QuickSMS = client.factory.create('obj_QuickSMS')
obj_QuickSMS.loginId = '91313212304269149'
obj_QuickSMS.loginPassword = 'zqong@435'
obj_QuickSMS.Destination = '923459332997'
obj_QuickSMS.Mask = 'Edex'
obj_QuickSMS.Message = 'HELLO'
obj_QuickSMS.UniCode = '0'
obj_QuickSMS.ShortCodePrefered = 'n'
result = client.service.QuickSMS(obj_QuickSMS)
我收到以下错误:
_call_chain中的文件“ /usr/lib/python2.7/urllib2.py”,第407行 结果= func(* args) http_open中的文件“ /usr/lib/python2.7/urllib2.py”,第1228行 返回self.do_open(httplib.HTTPConnection,req)> 在do_open中的文件“ /usr/lib/python2.7/urllib2.py”,行1198 引发URLError(err) urllib2.URLError:
答案 0 :(得分:1)
您的网址中有空格,应该像这样:
client = Client(url='https://cbs.zong.com.pk/reachcwsv2/corporatesms.svc?wsdl',
username='9231089894269149',
password='Zo98989ng@123', cache=None)