以下是一个 soap 的接口,往该接口的 funMain 方法上,传输一个 json,就可以发送短信了。这个是 php 的代码,显示失败
$url = 'http://***/wsApi?wsdl';
$content=’ this is a test message';
$funcode = '1002'; //自定义扩展代码(模块)
$ApplicationID = 'HsqjSYsn6QjTrqzdW'; //账号
$Password = '6VnLZlVwKf'; //密码
$paras = array(
'content' =>$content,
'funCode' =>$funcode,
'applicationId' =>$ApplicationID,
'password' =>$Password);
$sendInfo=array(
'sendId' =>'0',
'mobile' =>'18899990000'); //手机号码
$paras['sendInfo'] ][0]=$sendInfo;
$client = new soapclient($url);
$result=$client->funMain(json_encode($paras));
而用 python,是没有问题的。
import sys
import json
import suds
from suds.client import Client
url='http://***/wsApi?wsdl'
c=Client(url)
def sms(phonenumber,text):
data={\
'applicationId': 'HsqjSYsn6QjTrqzdW5K',\
'password': '6VnLZlVw',\
'funCode': '1002',\
'content': 'this is for what you want to sent',\
'sendInfo': [\
{\
'sendId': '0',\
'mobile': '188990000'\
}\
]\
}
data['content']=text
data['sendInfo'][0]['mobile']=phonenumber
d=json.dumps(data)
e=c.service.funMain(d)
if __name__=='__main__':
if len(sys.argv)!=3:
print ('Usage:python need 2 string')
exit(1)
phonenumber=sys.argv[1]
text=sys.argv[2]
try:
sms(phonenumber,text)
except:
print ('duanxinji failure')