【发布时间】:2011-12-21 23:18:44
【问题描述】:
是否有任何 Perl 模块可用于向 Office Communicator 发送消息? 我在 CPAN 中搜索但没有任何运气。 我可以使用 Python 或 Ruby 向 Office Communicator 发送消息吗? 我想从 Linux Box 中执行此操作。
【问题讨论】:
标签: perl sip office-communicator
是否有任何 Perl 模块可用于向 Office Communicator 发送消息? 我在 CPAN 中搜索但没有任何运气。 我可以使用 Python 或 Ruby 向 Office Communicator 发送消息吗? 我想从 Linux Box 中执行此操作。
【问题讨论】:
标签: perl sip office-communicator
由于“Office Communicator”使用的是 SIP 的修改版本,您可以尝试使用 SIP 客户端,例如 Net::SIP(或同一软件包中的 Net::SIP::Simple)。
【讨论】:
我猜一年多后你会找到一个解决方案,但是如果你只是想发送一个 SIP 消息编写一个 perl 程序,你可以看看这个方法:http://archive.cert.uni-stuttgart.de/bugtraq/2005/07/msg00276.html
可能的定制:
#!/usr/bin/perl
use strict;
use warnings;
use Socket;
sub SendSIPTo {
my ($from, $to, $text, $ProxyIP) = @_;
my $contentLength = length($text);
my $AT = '@';
my $domain = 'example.com';
my $ToURI = 'sip:' . $to . $AT . $domain;
my $FromURI = 'sip:' . $from . $AT . $domain;
my $MESG = "MESSAGE $ToURI SIP\/2.0\r
Via: SIP/2.0/UDP 10.10.10.10;branch=z9hG4bK8fe6.db5fade4.0\r
To: $ToURI\r
From: <$FromURI>;tag=578c0e59d7504cca4dc4a96522981b0a-0c8b\r
CSeq: 1 MESSAGE\r
Call-ID: 609ded3a79a9cbd5\r
Content-Length: $contentLength\r
User-Agent: perl\r
\r
" . $text;
my $proto = getprotobyname('udp');
socket(SOCKET, PF_INET, SOCK_DGRAM, $proto) ;
my $iaddr = inet_aton("0.0.0.0");
my $paddr = sockaddr_in(5060, $iaddr);
bind(SOCKET, $paddr) ;
my $port = 5060;
my $hisiaddr = inet_aton($ProxyIP) ;
my $hispaddr = sockaddr_in($port, $hisiaddr);
send(SOCKET, $MESG, 0, $hispaddr ) || warn "send $!\n";
return 'OK';
}
1;
【讨论】: