О сервисе Тарифы Требования Операторы Демо





Для Perl проектов

Отправка сообщения на Perl. Если Вы хотите посылать данные по шифрованному каналу - замените http на https:

%send_sms_result = AvisoSMS_interface("GetCreditBalance", ("smsUser" =>
"", "password" => ""));

%send_sms_result = AvisoSMS_interface("SendTextMessage",
                   ("smsUser" => "",
                   "password" => "",
                   "destinationAddress" => "1234567890",
                   "messageData" => "message!",
                   "sourceAddress" => "SMS",
                   "deliveryReport" => 1,
                   "flashMessage" => 0,
                   "validityPeriod" => 10080));

%send_sms_result = AvisoSMS_interface("GetMessageState",
                    ("smsUser" => "",
                    "password" => "",
                    "messageId" => "49CB733C"));



Процедура:

sub AvisoSMS_interface {

    my ($action, %parameters) = @_;
    my $method_params = ""; my $resulthash = "";

    foreach my $param (keys %parameters) { $method_params = $method_params
. "<$param>$parameters{$param}</$param>"; };

    my $result = SOAP::Lite
    -> default_ns('http://sms.avisosms.ru/gate.php')
    -> proxy('http://sms.avisosms.ru/gate.php')
    -> on_action( sub { sprintf '%s/%s',$_[0],$_[1] })
    -> call($action => (SOAP::Data->type(xml => $method_params)));

    unless ($result->fault) {
        $resulthash = $result->method;
        delete $$resulthash{"${action}Result"};
        $$resulthash{'Result'} = $result->result;
    } else {
#       print STDERR join ', ', $result->faultcode, $result->faultstring;
        $$resulthash{'Result'} = "SOAP error";
        $$resulthash{'faultcode'} = $result->faultcode;
        $$resulthash{'faultstring'} = $result->faultstring;
    }
    return %$resulthash;
};

 

 

Примеры кода

PHPPython,   Java,   Ruby on Rails,   Perl,   Delphi,   .NETC#,