<P>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??
<P>sub InIQ<BR>{<BR> my $sid = shift;<BR> my $iq = shift;
<P> my $id = $iq->GetID();<BR> print "id = $id\n"; # works
<P> my $type = $iq->GetType();<BR> print "type = $type\n"; #works
<P> my $xmlns = $iq->GetQueryXMLNS();<BR> print "xmlns = $xmlns\n"; #works
<P> foreach my $query ($iq->GetQuery->GetItems) {<BR> print ("JID = $query->GetItem()->GetJID\n"); # prints a hash<BR> print ("Name = $query->GetItem()->GetName\n"); # prints a hash<BR> print ("Subscription = $query->GetItem()->GetSubscription\n"); # prints a hash<BR> print ("Group = $query->GetItem()->GetGroup[0]\n"); # prints a hash<BR> }<BR>}
<P> <B><I>rebbaj rebbaj <rebbaj2000@yahoo.co.uk></I></B> wrote:
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">
<P>Thanks Matt and Chris for the replies.
<P>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...<BR>---------------------------------- <BR>use Net::Jabber qw();<BR><BR>my $Connection = new Net::Jabber::Client();<BR>$Connection->SetCallBacks(iq=>\&InIQ);
<P># request the roster from the server<BR>my $iq_req = Net::Jabber::IQ->new();<BR>$iq_req->SetIQ(type=>"get", id=>"mpt_1");</P>
<P># is there a native call to do this?<BR>$iq_req->InsertRawXML('<query xmlns="jabber:iq:roster"/>');<BR><BR>$Connection->Send($iq_req);</P>
<P>while(defined($Connection->Process())) { }
<P>sub InIQ # callback routine<BR>{<BR> my $sid = shift;<BR> my $iq = shift;<BR> $roster = $iq->XXXXXX(); # what should I be calling here?
<P> foreach $item (XXXXXXX) {<BR> print $item->XXXXX, "\n"; # print jid<BR> print $item->XXXXX, "\n"; # print name<BR> print $item->XXXXX, "\n"; # print ask<BR> print $item->XXXXX, "\n"; # print subscribe<BR> print $item->XXXXX, "\n"; # print group<BR>}
<P>}
<P> <B><I>Chris Wilkes <cwilkes-jabber@ladro.com></I></B> wrote:
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">On Sat, Jan 25, 2003 at 11:55:46PM +0000, rebbaj rebbaj wrote:<BR>> <BR>> I am trying to write a routine in Perl where I can send a iq roster<BR>> request and then parse through all the responses such that I can put<BR>> them in an array. While I could do this with a call such as "my<BR>> $roster = $iq->GetXML()" followed by a bunch of regular expressions,<BR>> this seems painfull.<BR><BR>What Perl module are you using to do the "$iq->GetXML()"? If you send<BR>me your code that does that I can add code to split out the results.</BLOCKQUOTE>
<P>
<P><BR>
<HR SIZE=1>
<A href="http://uk.yahoo.com/mail/tagline_xtra/?http://uk.docs.yahoo.com/mail_storage.html"><B><FONT face=Arial size=2>With Yahoo! Mail you can get a bigger mailbox -- choose a size that fits your needs</FONT></B></A><BR></BLOCKQUOTE><p><p><br><hr size=1><a href="http://uk.yahoo.com/mail/tagline_xtra/?http://uk.docs.yahoo.com/mail_storage.html"><b><font face="Arial" size="2">With Yahoo! Mail you can get a bigger mailbox -- choose a size that fits your needs</font></b></a><br>