Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

LWP::UserAgent::post gives me an odd response

by gideondsouza (Pilgrim)
on Dec 29, 2012 at 12:54 UTC ( #1010814=perlquestion: print w/ replies, xml ) Need Help??
gideondsouza has asked for the wisdom of the Perl Monks concerning the following question:

So I'm doing a POST request to github as part of an OAuth web flow authentication. (This is part of a sub in a Dancer app).

I use LWP::UserAgent::post() and the docs I linked to seem to say that method will return a HTTP::Response object. But I get a weird type.

When I send a post to github for the access_token is where I have a slight problemo:

my $code = params->{'code'}; my $browser = LWP::UserAgent->new; my $resp = $browser.post('https://github.com/login/oauth/access_token' +, [ client_id =>'<my client id>' client_secret => '<my secret>', code => $code,#the code I got in the param state => '<some state>' ]); #HERE>>>>>>>>>>>>>>>>>>>> # I cannot seem to figure what $resp is!?? #----- $resp->is_success doesn't work! return Dumper($resp);

    Issues
  1. If I use $resp->is_success then I get Can't locate object method "is_success"
  2. With the Data::Dumper I get the following response: $VAR1 = 'LWP::UserAgent=HASH(0x7fd8da50a690)Dancer::Route=HASH(0x7fd8da4dd6a8)';
Any ideas?? How should I go an inspect the object that is returned.? Am I getting two objects here?

Comment on LWP::UserAgent::post gives me an odd response
Download Code
Re: LWP::UserAgent::post gives me an odd response
by gideondsouza (Pilgrim) on Dec 29, 2012 at 13:08 UTC

    Dear Monks!

    I'm very sorry about this, seems all this nonsense was caused just because of this:

    $browser.post(
    Instead of
    $browser->post(
    :S Seems I've got a lot of practising to do!! Sorry for the trouble again!!
      No need to apologize - particularly in a case where the syntax is not caught by the interpreter.

      You get ++ for self correction.

                   "By three methods we may learn wisdom: First, by reflection, which is noblest; Second, by imitation, which is easiest; and third by experience, which is the bitterest."           -Confucius

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (11)
As of 2014-10-01 20:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (38 votes), past polls