[JDEV] JUD Example
DJ Adams
dj.adams at pobox.com
Fri Dec 21 14:33:58 CST 2001
On Wed, Dec 19, 2001 at 01:23:32PM -0500, Michael Bauer wrote:
>
> Anyone have a simple on how to query a JUD, either using Perl or PHP?
> Something using DJ's new Perl tools would be most cool.
Hi Michael
How about this for starters?
#!/usr/bin/perl
use warnings;
use strict;
use Jabber::Connection;
use Jabber::NodeFactory;
use Jabber::NS qw(:all);
my $jud = 'users.jabber.com';
my $nf = new Jabber::NodeFactory;
my $c = new Jabber::Connection(server => 'jabber.host.com');
$c->connect or die "Cannot connect";
$c->auth('user','password','resource');
my $iq = $nf->newNode('iq');
$iq->attr('type', IQ_GET);
$iq->attr('to', $jud);
my $query = $iq->insertTag('query', NS_SEARCH);
my $result = $c->ask($iq);
foreach my $field ($result->getTag('query')->getChildren) {
print $field->name, "\n";
}
$c->disconnect;
Hope that helps
dj
More information about the JDev
mailing list