Jabber::Connection and Rosters
Simon Wistow
simon at thegestalt.org
Thu Jul 12 12:46:36 BST 2007
I'm trying to get the roster off a Jabber server and ... I can't get it
to work.
I've attached the script I've but I just never seem to get an IQ
messages.
Any ideas what I'm doing wrong?
Pointers to other modules with code hints also appreciated.
Simon
#!/usr/bin/perl -w
use strict;
use Jabber::Connection;
use Jabber::NodeFactory;
use Jabber::NS;
use Data::Dumper;
my $server = 'livejournal.com';
my $user = 'xxxx';
my $pass = 'xxxx';
my $port = 5222;
my $resource = time().$$.rand();
my $nf = Jabber::NodeFactory->new;
my $c = Jabber::Connection->new(server => $server.':'.$port, log => 0);
$c->connect || die $c->lastError;
$c->register_handler('iq', \&on_iq_message );
$c->auth($user, $pass, $resource);
my $iq = $nf->newNode('iq');
$iq->attr('type', Jabber::NS::IQ_GET());
$iq->insertTag('query', Jabber::NS::NS_ROSTER());
$c->send('<presence/>');
$c->send($iq);
$c->start;
$c->disconnect;
sub on_iq_message {
print "Got an iq message\n";
print Dumper(@_);
}
More information about the london.pm
mailing list