Net::Twitter::Search Twitter Search
use Net::Twitter::Search; my $twitter = Net::Twitter::Search->new(); my $results = $twitter->search('Albi the racist dragon'); foreach my $tweet (@{ $results }) { my $speaker = $tweet->{from_user}; my $text = $tweet->{text}; my $time = $tweet->{created_at}; print "$time <$speaker> $text\n"; } #you can also use any methods from Net::Twitter. my $twitter = Net::Twitter::Search->new(username => $username, password => $password); my $steve = $twitter->search('Steve'); $twitter->update($steve .'? Who is steve?');
For searching twitter - handy for bots
required parameter: query
returns: hash
Find tweets containing a word $results = $twitter->search('word');
Find tweets from a user: $results = $twitter->search('from:br3nda');
Find tweets to a user: $results = $twitter->search('to:serenecloud');
Find tweets referencing a user: $results = $twitter->search('@br3ndabot');
Find tweets containing a hashtag: $results = $twitter->search('#perl');
Combine any of the operators together: $results = $twitter->search('solaris anger from:br3nda');
$results = $twitter->search('hello', {lang=>'en'}); #search for hello in maori $results = $twitter->search('kiaora', {lang=>'mi'});
$results = $twitter->search('love', {rpp=>'10'});
#get page 3 $results = $twitter->search('love', {page=>'3'});
$results = $twitter->search('coffee', {geocode=> '40.757929,-73.985506,25km'});
Note that you cannot use the near operator via the API to geocode arbitrary locations; however you can use this geocode parameter to search near geocodes directly.
Net::Twitter
Brenda Wallace <shiny@cpan.org>
To install Net::Twitter::Search, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Twitter::Search
CPAN shell
perl -MCPAN -e shell install Net::Twitter::Search
For more information on module installation, please visit the detailed CPAN module installation guide.