标签:
一、简介
移动梦网短信平台可以通过SOAP、HTTP GET、HTTP POST方式发送短信,下面是我用perl写的通过SOAP发送短信的脚本,它比梦网提供的php、java小多了,可以和nagios等系统集成;
二、用法
查询余额: sendMsgSOAP.pl -u user -p password -b
发送短信: sendMsgSOAP.pl -u user -p password -r receiver -m message
三、源代码
#!/usr/bin/perl -w #hupeng@gkkxd.com use strict; use 5.10.1; use Getopt::Std; use SOAP::Lite; use Encode; use vars qw/ $opt_u $opt_p $opt_r $opt_m $opt_b /; getopts(‘u:p:r:m:b‘); #查询余额 #USAGE: $0 -u user -p password -b if( $opt_b && $opt_u && $opt_p ){ my $soap = SOAP::Lite -> uri(‘http://tempuri.org‘) -> proxy(‘http://61.145.229.29:7903/MWGate/wmgw.asmx‘, timeout=>5); my $som = $soap->call(‘MongateQueryBalance‘, SOAP::Data->name(‘userId‘)->value($opt_u), SOAP::Data->name(‘password‘)->value($opt_p) ); die $som->faultstring if ($som->fault); print $som->result, "\n"; #发送短信 #USAGE: $0 -u user -p password -r receiver -m message }elsif( $opt_u && $opt_p && $opt_r && $opt_m ){ my $msg = decode(‘utf8‘,$opt_m); my $count = split(‘,‘,$opt_r); my $soap = SOAP::Lite -> uri(‘http://tempuri.org‘) -> proxy(‘http://61.145.229.29:7903/MWGate/wmgw.asmx‘, timeout=>5); $soap->serializer->autotype(0); my $som = $soap->call(‘MongateSendSubmit‘, SOAP::Data->name(‘userId‘)->value($opt_u), SOAP::Data->name(‘password‘)->value($opt_p), SOAP::Data->name(‘pszMobis‘)->value($opt_r), SOAP::Data->name(‘pszMsg‘)->value($msg), SOAP::Data->name(‘iMobiCount‘)->value($count), SOAP::Data->name(‘pszSubPort‘)->value(‘*‘), SOAP::Data->name(‘MsgId‘)->value(‘0‘) ); die $som->faultstring if ($som->fault); print $som->result, "\n"; }else{ print "查询余额: $0 -u user -p password -b\n"; print "发送短信: $0 -u user -p password -r receiver -m message\n"; exit(1); }
标签:
原文地址:http://www.cnblogs.com/hahp/p/4226289.html