Can't understand how to find latest twitt id in perl API


I’m using Net::Twitter and writing small and simple script in perl. All I need in it is to get id for the latest twitt sent by the authenticating user (let’s say mine). I’ve tryed home_timeline, but with no success. If anybody can help and show proper perl syntax I will be pleased. Thank you in advance!


I’m not sure what the appropriate Perl syntax would be, but you can find the latest status of any user inside the users/show endpoint. Inside the user object returned, you will find a status object with an id and text values.


A very simple example (without error handling and such) would be:

use Net::Twitter;

my $nt = Net::Twitter->new(
    traits              => [qw/API::RESTv1_1/],
    consumer_key        => "Consumer Key (API Key)",
    consumer_secret     => "Consumer Secret (API Secret)",
    access_token        => "Access Token",
    access_token_secret => "Access Token Secret",

my $statuses = $nt->user_timeline({ count => 1 });
print "Latest Tweet:    $$statuses[0]->{created_at}\n";
print "Latest Tweet ID: $$statuses[0]->{id_str}\n";


andypiper, in perl Twitter API where is “user_timeline”, not “user”.

ePirat, yes, it’s exactly what I wanted: single-line. Thanks a lot!

closed #5