首页 > 学院 > 操作系统 > 正文

[工具开发] 移动梦网短信发送客户端

2024-06-28 13:22:29
字体:
来源:转载
供稿:网友
[工具开发] 移动梦网短信发送客户端

一、简介

移动梦网短信平台可以通过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 -bif( $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);}


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表