Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Net::Twitter::Lite::WithAPIv1_1 bad request

by xavandar (Initiate)
on Apr 17, 2017 at 09:52 UTC ( [id://1188113]=perlquestion: print w/replies, xml ) Need Help??

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

i try to post hello world and all time :
C:\a>perl hello.pl Net::Twitter::Lite::WithAPIv1_1=HASH(0x31ec738) 400: Bad Request C:\a> use Net::Twitter::Lite::WithAPIv1_1; use Scalar::Util 'blessed'; # use strict; # When no authentication is required: #my $nt = Net::Twitter->new(legacy => 0); # As of 13-Aug-2010, Twitter requires OAuth for authenticated reques +ts my $nt = Net::Twitter::Lite::WithAPIv1_1->new( traits => [qw/API::RESTv1_1/], consumer_key => "xxxxxxxxxxxxxxxx", consumer_secret => "xxxxxxxxxxxxxxx", oauth_token => "xxxxxxxxx", oauth_token_secret => "xxxxxxxxxxx", ssl =>1, apiurl => 'http://api.twitter.com/1.1' ); print "\n"; print $nt."\n"; eval { my $result = $nt->update('Hello, world! from perl')}; #my $result = $nt->update =>({status =>'Hello, world from perl and n +et:twitter!'}); #print $result."dansleprint\n"; if ( my $err = $@ ) { die $@ unless blessed $err && $err->isa('Net::Twitter::Error'); warn "HTTP Response Code: ", $err->code, "\n", "HTTP Message......: ", $err->message, "\n", "Twitter error.....: ", $err->error, "\n"; }

Replies are listed 'Best First'.
Re: Net::Twitter::Lite::WithAPIv1_1 bad request
by marto (Cardinal) on Apr 17, 2017 at 09:57 UTC
    apiurl => 'http://api.twitter.com/1.1'

    "Sorry, that page doesn’t exist!", so that's wrong. I don't have an apiurl in my working config:

    my $twitter = Net::Twitter::Lite::WithAPIv1_1->new( access_token_secret => $config->{TWITTER_ACCESS_SECRET}, consumer_secret => $config->{TWITTER_CONSUMER_SECRET}, access_token => $config->{TWITTER_ACCESS_TOKEN}, consumer_key => $config->{TWITTER_CONSUMER_KEY}, user_agent => 'TwitterBotExample', ssl => 1, );

    Update my code was based on this short tutorial.

    Update: fixed link.

Re: Net::Twitter::Lite::WithAPIv1_1 bad request
by Mr. Muskrat (Canon) on Apr 19, 2017 at 14:12 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-20 03:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found