http://qs321.pair.com?node_id=250054

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

There are no present errors however the message still isn't sending. Anyone who's familiar with Net::Aim have any idea why?
#!/usr/bin/perl use strict; use warnings; my $user = "wfgs343R"; my $pass = "iamcool"; my $aim; print "Subject's Name:"; chomp(my $destuser = <STDIN>); print "Message:"; chomp(my $message = <STDIN>); use Net::AOLIM; $aim = Net::AOLIM->new( 'username' => $user, 'password' => $pass, 'callback' => \&callbackfunction, 'server' => 'toc.oscar.aol.com', 'port' => 1234, 'allow_srv_settings' => 1, 'login_server' => 'login.oscar.aol.com', 'login_port' => 5198, 'login_timeout' => 0, ); print "Information is being passed.\n"; $aim->signon(); print "Aim is signed on.\n"; $aim->toc_send_im($destuser, $message); print "Done\n";

Replies are listed 'Best First'.
Re: Net::Aim (again)
by sutch (Curate) on Apr 12, 2003 at 15:11 UTC
    Your title is incorrect, it should be Net::AOLIM instead of Net::AIM.

    When executing example.pl that is included with Net::AOLIM, I get the following error:

    Use of uninitialized value in array dereference at /usr/lib/perl5/site +_perl/5.6.1/Net/AOLIM.pm line 946, <> line 2.
    Maybe AOL has made some change to the protocol.

    I've been able to use Net::AIM without too many problems. You may want to try that package instead.

      I was hesitant to use Net::Aim due to the lack of information on the cpan module page. With AOLIM atleast they should examples of how to use it.

      In any case, I implemented a fast copy using Net::Aim and I'm getting an error :PARSE: How many args in ' 2'?

      The script hangs after "Login Successful". Any suggestions?

      #!/usr/bin/perl use strict; use warnings; use Net::AIM; my $aim; my $conn; print "Subject's name:"; chomp(my $destuser = <STDIN>); print "Message:"; chomp(my $message = <STDIN>); print "Starting Net::Aim\n"; $aim = new Net::AIM; print "Connecting with loging crudentials\n"; $conn = $aim->newconn(Screenname => 'wfgs343R', Password => 'iamcool'); print "Login sucessfull!\n"; $aim->start; print "Beginning AIM\n"; $aim->send_im($destuser, $message); print "Message sent.\n";
        It's been a while since I've done anything useful with Net::AIM, but I remember that it needs to handle some config events before any messages can be sent. I also noticed that AIM will not send messages if the connection is closed too soon (thus the sleep).

        This code below does the job. DEBUG is on to show some useful information, but I'd also suggest adding some print statements to gain an even better understanding of how Net::AIM functions.

        #!/usr/bin/perl use strict; use Net::AIM; sub DEBUG() { 1 } my $aim = new Net::AIM; $aim->debug(1) if (DEBUG); # provides helpful information $aim->newconn( Screenname => 'my_name', Password => 'my_password' ) or + die "Can't connect to AIM server.\n"; my $conn = $aim->getconn(); $conn->set_handler('config', \&on_config); $aim->set('config_done', 0); my $done = 0; while (! $done) { $aim->do_one_loop(); if ($aim->get('config_done')) { $aim->send_im('my_buddy', 'my_message'); sleep 5; $done = 1; } else { $aim->do_one_loop(); } } sub on_config { my ($self, $evt, $from, $to) = @_; my $str = shift @{$evt->args()}; $self->set_config_str($str, 1); $self->send_config(); $self->set('config_done', 1); }
        From Net::AIM:
        $aim->start()
            This just starts an infinte loop of $aim->do_one_loop;
        If you take out the $aim->start;, your script should work.

        Update Hmm, just tried it and it doesn't work. You might need to set some type of handler to send the message and then do the $aim->start...

Re: Net::Aim (again)
by The Mad Hatter (Priest) on Apr 12, 2003 at 17:04 UTC
    Aha! I was just fooling around with Net::AIM trying to get it to do what you want (I was able to send the message by using a handler called when first logged on, but I can't exit without screwing up the handler.) and I think I figured out at least part of your problem.

    It seems that AOL will block users who connect and disconnect frequently. I ran into this problem when suddenly it wasn't sending messages anymore. I tried to log on using GAIM (a very nice AIM client for Linux) and got the message about connecting and disconnecting too much. If you've been testing with the same username, you might want to try and register a different to test with; either that or wait for a good amount of time before trying again.