rgens has asked for the wisdom of the Perl Monks concerning the following question:

Wise ones,

I am able to use Net::AIM on a CGI webserver to log-in and send messages, but whenever I:
print $aim->get_info("screenname");
a number is printed that follows the formula 20 + X, where X is the number of characters in the screenname.

How do I actually get the info of a user? Is it a matter of making a weird handler?

Enlighten me.

Replies are listed 'Best First'.
Re: CGI Net::AIM get_info()
by Roger (Parson) on Jan 16, 2004 at 06:09 UTC
    The documentation says:
    $aim->get_info($screen_name) Sends an info request to the server for $screen_name. The server should reply with a URL which will contain the info requested about the user.

    I suggest you to have a look at what's returned by get_info by using the Data::Dumper module:
    use Data::Dumper; ... my $result = $aim->get_info("screenname"); print Dumper($result); ...

      Trying to get the info of a 7 character screenname and using Data::Dumper, it simply prints:
      $VAR1 = 27;
      (Notice the 20+7 pattern)
        I checked the source code of Net::AIM::Connection, where the get_info method is defined, and found that it returns the value returned by the send_to_AOL method. The following is the code of send_to_AOL:
        sub send_to_AOL { ... my $rv = send($self->{_socket}, $data, 0); ... return $rv; }
        Note that the return value of socket send is the number of characters sent. That explains why you are getting a numeric value in the return value of get_info. You have found a bug in the Net::AIM::Connection module it seems. ;-)

        I think you might be able to get around this problem by calling the method do_one_loop after the get_info, where do_one_loop reads the socket:
        $aim->get_info("screenname"); $response = $aim->do_one_loop();

Re: CGI Net::AIM get_info()
by castaway (Parson) on Jan 16, 2004 at 10:57 UTC
    I'd assume, looking at the module, that you are supposed to create an event handler. 'Server returns a URL' isnt very helpful though.

    My suggestion: switch to Net::OSCAR, which is much better documented. (there you need to create a callback/handler for 'buddy_info', maybe its the same name for the event in Net::AIM?)

    C.