使用python发送请求很简单。
xml = \
"""
<?xml version="1.0" encoding="UTF-8"?>
<request>
<head>
<operation>submit</operation>
<login>user</login>
<password>pass</password>
<title>title</title>
<isbulk>false</isbulk>
<scheduled>2018-04-04 17:55:05</scheduled>
<controlid>188</controlid>
</head>
<body>
<msisdn>676775</msisdn>
<message>test from code</message> </body>
</request>"""
headers = {'Content-Type': 'text/xml'} # set what your server accepts
req = requests.post('sms.xxxx.xxx/bulksms/api', data=xml,
headers=headers)
print req.text
<?xml version="1.0" encoding="UTF-8"?><response><head> .
<responsecode>300</responsecode></head></response>
使用suds
from suds.client import Client
url="https://xxxxx/bulksms/api"
client = Client(url)
print client #there isnt any service
但我可以使用api测试应用程序发送短信。如何使用python代码发送短信?为什么我可以使用应用程序发送,但它总是在代码中返回300?