-
Notifications
You must be signed in to change notification settings - Fork 54
Multifon sms
Mikhail Kotelnikov edited this page Feb 21, 2016
·
4 revisions
#!/usr/bin/perl -w
use utf8;
use strict;
use warnings FATAL => 'uninitialized';
use Encode;
use lib '.';
use Yate;
use MIME::Base64;
sub send_sms
{
my($yate, $my_phone_number, $receiver_phone_number) = @_;
my $msgid = $yate->generate_id;
$yate->message('xsip.generate', undef, $msgid,
method => 'MESSAGE',
uri => qq{sip:+$receiver_phone_number\@sms.multifon.ru},
'sip_X-Movial-Content' => 'sms/text',
'sip_X-Movial-DeliveryReport' => 'true',
# Можно так:
# xsip_body => encode_base64(Encode::encode('UCS-2', "Не. Ну Ёлы-палы!")),
# xsip_type => 'text/plain; charset=ISO-10646-UCS-2',
# xsip_body_encoding => 'base64',
# Можно сяк:
xsip_body => unpack("H*", Encode::encode('UCS-2', "Абалдеть можно")),
xsip_type => 'text/plain; charset=ISO-10646-UCS-2',
xsip_body_encoding => 'hex',
sip_From => qq{"SMS Sender" <sip:$my_phone_number\@multifon.ru>}, # "x" <[email protected]>
'sip_User-Agent' => 'MCPC-MG-1-0-34-3490/2.0.0.5301', # required
line => 'multifon',
);
return $msgid;
}
my $y = new Yate(Debug=>0);
# the following 'connect' method requires modified Yate.pm (https://github.com/vir/yate/blob/master/share/scripts/Yate.pm)
$y->connect("192.168.a.bb:ppppp");
send_sms($y, '7921xxxxxxx', '7921yyyyyyy');
[multifon]
enabled=yes
protocol=sip
username=7921xxxxxxx
authname=7921xxxxxxx
password=PASSWORDPASSWORD
domain=multifon.ru
registrar=multifon.ru
outbound=sbc.multifon.ru
formats=alaw,mulaw
[listener 1]
type=tcp
addr=192.168.a.bb
port=ppppp
; ...
^694\(.*\)$=sip/\[email protected] ; line = multifon; rtp_forward=no; formats=alaw,mulaw; format=alaw; caller=7921xxxxxxx; domain=multifon.ru
; ...
[general]
generate=enable
; ...