Domanda

C'è qualche Perl modulo a disposizione per inviare messaggi a Office Communicator? Ho cercato in CPAN, ma senza alcuna fortuna. Posso usare Python o Ruby per inviare messaggi a Office Communicator. Voglio fare questo da una macchina Linux.

È stato utile?

Soluzione

"Office Communicator" sta usando una versione modificata di SIP, è possibile provare a utilizzare client SIP come Net :: SIP (o Net :: :: Simple SIP da stesso package).

Altri suggerimenti

Credo che avrete trovato una soluzione, dopo più di un anno, ma comunque, se si desidera inviare un messaggio SIP a scrivere un programma Perl, si può dare un'occhiata a questo approccio: http://archive.cert.uni-stuttgart.de/bugtraq/2005/07/msg00276 .html

Una personalizzazione possibile:

#!/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;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top