|
Rebbaj,
I found a segment of code in my files listed
in following, and
you can see that I am using "$iq->GetXML()" and
"$iq_result->GetXML()"
to check the IQ packet to be sent and the IQ packet
result.
As long as the format of XML is right, it should work.
So, please check your XML before sending.
Good luck.
-Yanming
...
print "Connecting:
$username\@$server:$port/$resource\n";
# initialize the Jabber client
object
# $Connection = new Net::Jabber::Client(debuglevel=>2, debugfile=>"debug", debugtime=>1); $Connection = new Net::Jabber::Client; print ".\n";
# try the connection and get the status of it $status = $Connection->Connect("hostname" => $server, "port" => $port); print ".\n"; # If something's wrong with the connection if (!(defined($status))) { print "<br />ERROR: Jabber server is down or connection was not allowed.\n"; print "<br />($!)\n"; &print_file("./jru-bottom.inc"); exit(0); } print ".\n";
# Set callbacks for incoming info
$Connection->SetCallBacks("message" => \&InMessage, "presence" => \&InPresence, "iq" => \&InIQ); # Connect!
$Connection->Connect(); print ".\n"; # Try authorization @result = $Connection->AuthSend("username" => $username, "password" => $password, "resource" => $resource); print ".\n"; # If the auth went awry if ($result[0] ne "ok") { print "<br />ERROR: Authorization failed: $result[0] - $result[1]\n<br />"; exit(0); } print ".\n"; print "<br />Logged in successfully to $server:$port as $username...\n"; # print "<br />Getting your
roster...\n";
# # this step is important --- to behavior as a regualr Jabber client. # %roster = $Connection->RosterGet(); ### Start of Subscription ####
print "<br />Sending
presence...\n";
$Connection->PresenceSend(); #$Connection->Process(1); my ($iq, $iq_query, $iq_result, my $from);
# #<iq id="jcl_44" to="[EMAIL PROTECTED]" type="set"> # <query xmlns="jabber:iq:register"> # <nick>reminder</nick> # </query> #</iq> # $from = "$username\@$server/$resource";
print "<br />from= $from\n";
$iq = Net::Jabber::IQ->new();
$iq->SetIQ( from => $from, type => 'set', to => $service_jid, id => 'jru_02', query => 'info' ); $iq_query =
$iq->NewQuery("jabber:iq:register");
$iq_query->SetNick($nick); print "<br />Sending iq...\n".$iq->GetXML()."\n";
$iq_result = $Connection->SendAndReceiveWithID($iq, 1);
# Success if ($iq_result->GetType() eq 'result') { print "<br />"; print $iq_result->GetXML(); print "<br />\n"; } # Failure else { print "<br />Error: ", $iq_result->GetErrorCode(), " (", $iq_result->GetError(), ")\n"; # # print "<br />ERROR: IQ failed: $result[0] - $result[1]\n<br />"; # print "<br /><TEXTAREA NAME=RECV ROWS=10 COLS=70>\n"; # print $result->toStr; # print "</TEXTAREA><br />\n"; # exit(0); } #$Connection->Process(1);
##########################
my $presence = Net::Jabber::Presence->new(); $presence->SetTo($service_jid); #$presence->SetFrom($from); $presence->SetType('subscribed'); #while( $first_run && defined($Connection->Process())) print "<br />Sending presence...\n".$presence->GetXML()."\n"; $iq_result = $Connection->SendAndReceiveWithID($presence, 1); ### End of Subscription #### # Should be all done, so why don't we disconnect?
Sounds like fun to me.. but fun to you? Could be. Give it a shot,
anyway...
print "<br />Disconnecting...\n"; # #$do_subscribe = ''; #$query->delete_all(); #print $query->start_multipart_form(); #print $query->end_form(); # $Connection->Disconnect(); print "<br />Disconnected.\n"; # print "\n<script
type=\"text/_javascript_\">\n<!--\nfunction popUpLog() {\n newWindow =
window.open('', 'newWin',
'toolbar=no,location=no,scrollbars=yes,resizable=yes,width=300,height=300')\n\n
newWindow.document.write(\"<html><head><title>Jabber roster
utility Log</title></head><body bgcolor=ffffff
text=000000><b><font face=sans-serif><div align=left><br
/>", $log,
"</div></font></b></body></html>\")\n}\n -->\n
</script>";
# print "<br /><a href="" return true;\">Click here</a> to view a log of all users updated and all errors.\n<br /><br />"; # # print "<hr width=\"75%\" noshade=\"noshade\" />"; ----- Original Message -----
From: rebbaj
rebbaj
Sent: Tuesday, January 07, 2003 5:39 PM
Subject: Re: [JDEV] Proper use of Perl Net::Jabber calls Thanks Yanming. I took a good long look at the code found at http://www.jabberstudio.org/cgi-bin/viewcvs.cgi/*checkout*/netjabber/examples/client.pl?rev=1.4&content-type=text/plain What I still do not understand is why the $Connection->RosterGet(); call does not result in all of the roster entries being sent back from the server and hence triggering the sub InIQ routine. If I manually enter the following XML "<iq type="get"><query xmlns="jabber:iq:roster"/></iq>, I get all the entries back. The docs state "RosterGet() - sends an empty Net::Jabber::IQ::Roster tag to the server so the server will send the Roster to the client." Any other ideas? Regards, Rebbaj Yanming Xiao <[EMAIL PROTECTED]> wrote:
With Yahoo! Mail you can get a bigger mailbox -- choose a size that fits your needs |
- [JDEV] Proper use of Perl Net::Jabber calls rebbaj rebbaj
- Re: [JDEV] Proper use of Perl Net::Jabber calls Yanming Xiao
- Re: [JDEV] Proper use of Perl Net::Jabber calls rebbaj rebbaj
- Re: [JDEV] Proper use of Perl Net::Jabber calls Yanming Xiao
- [JDEV] Proper use of Perl Net::Jabber calls rebbaj rebbaj
- Yanming Xiao
