How to Use Net Twitter PERL
Twitter provides Web application developers with an API you can use to connect to the service and display tweets from your account. Even though Perl is an older language, it's still compatible with the Twitter API, so you can update older pages to use the Twitter feed. You must use your Twitter username and password to connect and search for tweets.
Instructions
-
-
1
Right-click the Perl file you want to edit and select "Open With." Click your preferred Perl editor to load the code in the editor.
-
2
Create the connection to the Perl API. The following code connects to your Twitter API feed:
my $nt = Net::Twitter->new(
traits => [qw/OAuth API::REST/],
consumer_key => $consumer_key,
consumer_secret => $consumer_secret,
access_token => $token,
access_token_secret => $token_secret,
);Replace each value with the information for your own Twitter API account.
-
-
3
Retrieve the list of results and assign them to a new Perl variable. For example, retrieve a list of tweets with the term "peter:"
my $result = $nt->update('peter'); -
4
Display the information to the reader. The following code shows the resulting data to the user including the Twitter user and the message:
print "$status->{created_at} <$status->{user}{screen_name}> $status->{text}\n";
-
1