[JDEV] Perl code sample needed...

rebbaj rebbaj rebbaj2000 at yahoo.co.uk
Sun Jan 26 14:29:08 CST 2003


After some more testing, I got the impression that the following callback logic would work.  Getting the <item>s does not seem to work.  Has anybody ever made this work before?? 
sub InIQ
{
 my $sid = shift;
 my $iq = shift; 
 my $id = $iq->GetID();
 print "id = $id\n"; # works 
 my $type = $iq->GetType();
 print "type = $type\n"; #works 
 my $xmlns = $iq->GetQueryXMLNS();
 print "xmlns = $xmlns\n"; #works 
 foreach my $query ($iq->GetQuery->GetItems) {
  print ("JID = $query->GetItem()->GetJID\n"); # prints a hash
  print ("Name = $query->GetItem()->GetName\n");  # prints a hash
  print ("Subscription = $query->GetItem()->GetSubscription\n"); # prints a hash
  print ("Group = $query->GetItem()->GetGroup[0]\n"); # prints a hash
 }
} 
 rebbaj rebbaj <rebbaj2000 at yahoo.co.uk> wrote: 
Thanks Matt and Chris for the replies. 
It seemed reasonable that one could write an algorighm as follows with the Net::Jabber pm.  What would the XXXX's be?  I would also like to do this with the returned presence data...
----------------------------------  
use Net::Jabber qw();

my $Connection = new Net::Jabber::Client();
$Connection->SetCallBacks(iq=>\&InIQ); 
#  request the roster from the server
my $iq_req = Net::Jabber::IQ->new();
$iq_req->SetIQ(type=>"get", id=>"mpt_1");

# is there a native call to do this?
$iq_req->InsertRawXML('<query xmlns="jabber:iq:roster"/>');

$Connection->Send($iq_req);

while(defined($Connection->Process())) { } 
sub InIQ # callback routine
{
 my $sid = shift;
 my $iq = shift;
 $roster = $iq->XXXXXX(); # what should I be calling here? 
 foreach $item (XXXXXXX) {
      print $item->XXXXX, "\n"; # print jid
      print $item->XXXXX, "\n"; # print name
      print $item->XXXXX, "\n"; # print ask
      print $item->XXXXX, "\n"; # print subscribe
      print $item->XXXXX, "\n"; # print group
} 
} 
 Chris Wilkes <cwilkes-jabber at ladro.com> wrote: On Sat, Jan 25, 2003 at 11:55:46PM +0000, rebbaj rebbaj wrote:
> 
> I am trying to write a routine in Perl where I can send a iq roster
> request and then parse through all the responses such that I can put
> them in an array. While I could do this with a call such as "my
> $roster = $iq->GetXML()" followed by a bunch of regular expressions,
> this seems painfull.

What Perl module are you using to do the "$iq->GetXML()"? If you send
me your code that does that I can add code to split out the results.



---------------------------------
With Yahoo! Mail you can get a bigger mailbox -- choose a size that fits your needs




---------------------------------
With Yahoo! Mail you can get a bigger mailbox -- choose a size that fits your needs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.jabber.org/jdev/attachments/20030126/ecef89b3/attachment-0002.htm>


More information about the JDev mailing list