Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

LWP:UserAgent Use of uninitialized value in subroutine entry at blib\lib\Net\SSLeay.pm

by cormanaz (Chaplain)
on Mar 26, 2013 at 10:06 UTC ( #1025484=perlquestion: print w/ replies, xml ) Need Help??
cormanaz has asked for the wisdom of the Perl Monks concerning the following question:

Good day Bros. I am using LWP::UserAgent to do a POST access the Twitter API like so
my $ua = new LWP::UserAgent; my $req = new HTTP::Request 'POST','https://api.twitter.com/1/users/lo +okup.json'; $req->content_type('application/x-www-form-urlencoded'); $req->content('user_id='.join(",",keys %missingusers)); my $res = $ua->request($req);
and am getting an error Use of uninitialized value in subroutine entry at blib\lib\Net\SSLeay.pm (autosplit into blib\lib\auto\Net\SSLeay\randomize.al) line 888. Thing is, this doesn't seem to prevent a response. Anyone know what is going on?

Comment on LWP:UserAgent Use of uninitialized value in subroutine entry at blib\lib\Net\SSLeay.pm
Select or Download Code
Re: LWP:UserAgent Use of uninitialized value in subroutine entry at blib\lib\Net\SSLeay.pm
by McA (Priest) on Mar 26, 2013 at 10:18 UTC

    Hi,

    you try to access the API via HTTPS as the URL shows. Are you sure that you have LWP::Protocol::https installed which is necessary to do such a request? Just a guess.

    McA

      LWP::Protocol::https 6.03 is installed and verified.
Re: LWP:UserAgent Use of uninitialized value in subroutine entry at blib\lib\Net\SSLeay.pm
by daxim (Chaplain) on Mar 26, 2013 at 10:32 UTC
    It looks like you haven't installed Net::SSLeay properly, but instead include a directory path to an unpacked and half-built distro archive. Is my guess correct? If yes, why did you do so and where did you learn that?

    Is that your whole code? Why don't you use an existing Twitter module (e.g. Net::Twitter) instead of reinventing it poorly?

      Net::SSleay was apparently installed with the current version of ActiveState Perl. PPM reports that it is installed in the perl location rather than site. It's not the most current version tho--it's 1.39. Looking at some of the CPAN testers reports, the later versions seem not to test out well on win32 platforms, and even 1.39 does not get a clean report, so maybe that's the problem.

      I didn't use Net::Twitter because the code is going to run on a system where I don't have privileges to install non-standard modules. And how do you know I've reinvented it poorly? It's straightforward to get the string and decode the JSON so no big deal. It's neither necessary nor helpful to be so condescending.

        The latest version builds for me with zero issues with Strawberry Perl 5.16.2, Windows 7 64bit.

Re: LWP:UserAgent Use of uninitialized value in subroutine entry at blib\lib\Net\SSLeay.pm
by Khen1950fx (Canon) on Mar 26, 2013 at 23:45 UTC
    %missingusers is the uninitialized value. If you look a little deeper you'll find out the real problem:
    #!/usr/bin/perl -l use strict; use warnings; use LWP::UserAgent; my $ua = new LWP::UserAgent; my $req = HTTP::Request->new( POST => 'https://api.twitter.com/1/users/lookup.json'); if ($ua->is_protocol_supported('https')) { print "HTTPS is allowed"; } else { print "This is HTTP-only"; } my $res = $ua->request($req); if ($res->is_success) { print $res->as_string; } else { print "Failed: ", $res->status_line; print $res->decoded_content; }
      I didn't post the whole code because nobody could run it--%missingusers gets populated from a database. It actually works despite throwing that error, so I don't understand why Net::SSleay is even invoked if it's not needed for LWP::UserAgent to work.

        "I don't understand why Net::SSleay is even invoked if it's not needed for LWP::UserAgent to work."

        Your target is https://api.twitter.com/1/users/lookup.json LWP::UserAgent states:

        "You will need to install LWP::Protocol::https separately to enable support for processing https-URLs."

        LWP::Protocol::https requires Net::SSleay.

        Update: fixed typo.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2014-12-27 13:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls