Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Getting gtalk user status using Net XMPP

by hello_world (Acolyte)
on Feb 26, 2012 at 10:20 UTC ( #956243=perlquestion: print w/ replies, xml ) Need Help??
hello_world has asked for the wisdom of the Perl Monks concerning the following question:

Hi Folks, I am trying to get the list of my roster and status of a particular buddy using the Net XMPP protocol. But for some odd reason,i can get the list of my entire roster but not the status of a particular buddy.
#!/usr/bin/perl use Net::XMPP; use Data::Dumper; my $username = ''; my $password = ''; my $resource = 'Perl'; my $hostname = 'talk.google.com'; my $port = 5222; my $componentname = 'gmail.com'; my $connectiontype = 'tcpip'; my $tls = 1; # Connect to Google Talk my $Connection = new Net::XMPP::Client(); my $stat = $Connection->Connect( hostname => $hostname, port => $port, tls => $tls, componentname => $componentname, connectiontype => $connectiontype, ) or die "Failed:$!\n";; my @res = $Connection->AuthSend( username => $username, password => $password, resource => $resource ) or die "Failed to Auth +:$!\n"; $Connection->PresenceSend(show=>'available'); my $roster = $Connection->Roster(); my @buddies = $Connection->RosterGet(); my $user = $roster->online('somebuddy@gmail.com'); print "Roster - @buddiesn"; print "User - $user\n"; while (my $x=$Connection->Process()) { }
what am i doing wrong here ? $user is undef !!

Comment on Getting gtalk user status using Net XMPP
Download Code
Re: Getting gtalk user status using Net XMPP
by Anonymous Monk on Feb 26, 2012 at 10:34 UTC

    can get the list of my entire roster but not the status of a particular buddy.

    Maybe that buddy is not in your roster?

    what am i doing wrong here ? $user is undef !!

    It appears you're not reading the fine manual (Net::XMPP::Roster), online returns undef when a user is not online

    Try Dumper-ing the results of query  my %hash = $Roster->query('bob@jabber.org');

      The buddy is in roster and is online as well,and when i print $user i get 'use of uninitialized value'. I tried dumping the results of %hash and its empty.

        I see two things to try, install DAPATRICK/Net-XMPP-1.02_04.tar.gz (  cpanp i DAPATRICK/Net-XMPP-1.02_04.tar.gz ) and test again. If problem persists, report bug upstream :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://956243]
Approved by Eliya
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2015-07-06 10:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (71 votes), past polls