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');
The search method also supports the following optional URL parameters:
Restricts tweets to the given language, given by an ISO 639-1 code.
$results = $twitter->search('hello', {lang=>'en'}); #search for hello in maori $results = $twitter->search('kiaora', {lang=>'mi'});
The number of tweets to return per page, up to a max of 100.
$results = $twitter->search('love', {rpp=>'10'});
The page number to return, up to a max of roughly 1500 results (based on rpp * page)
#get page 3 $results = $twitter->search('love', {page=>'3'});
Returns tweets with status ids greater than the given id.
$results = $twitter->search('love', {since_id=>'1021356410'});
returns tweets by users located within a given radius of the given latitude/longitude, where the user's location is taken from their Twitter profile. The parameter value is specified by "latitide,longitude,radius", where radius units must be specified as either "mi" (miles) or "km" (kilometers).
$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.