Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Net-Twitter CPAN distribution.

Report information
The Basics
Id: 54662
Status: rejected
Priority: 0/
Queue: Net-Twitter

People
Owner: Nobody in particular
Requestors: psmitty5 [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 3.11004
Fixed in: (no value)



Subject: Location Search not returning any results
Download (untitled) / with headers
text/plain 946b
Recently the Net::Twitter::Search module is failing to return any results for the geocode tag. Here is my script: use strict; use warnings; use Net::Twitter::Search; use Geo::Coder::Bing; my $town = 'my town'; my $state = 'my state'; my $zip = 'my zip'; my $near = "$town, $state, $zip"; my $units = 'mi'; my $twit = Net::Twitter::Search->new; my $geocoder = Geo::Coder::Bing->new; my $location = $geocoder->geocode( location => $near ); my $latitude = $location->{BestLocation}->{Coordinates}->{Latitude}; my $longitude = $location->{BestLocation}->{Coordinates}->{Longitude}; my %seen = (); for( 1..10 ) { my $result = $twit->search( { geocode => "$latitude,$longitude,$units", page => $_, rpp => 100 } ); for my $block ( @{$result->{results}} ) { if ( !$seen{ $block->{from_user} }++ ) { print "User: " . $block->{from_user} . "\n"; } } } Any idea what changed? Great module by the way :) Thanks, -Paul
Download (untitled) / with headers
text/plain 2.2k
On Tue Feb 16 08:56:45 2010, psmitty wrote: Show quoted text
> Recently the Net::Twitter::Search module is failing to return any > results for the geocode tag. > > Here is my script: > > use strict; > use warnings; > > use Net::Twitter::Search; > use Geo::Coder::Bing; > > my $town = 'my town'; > my $state = 'my state'; > my $zip = 'my zip'; > > my $near = "$town, $state, $zip"; > my $units = 'mi'; > > my $twit = Net::Twitter::Search->new; > > my $geocoder = Geo::Coder::Bing->new; > my $location = $geocoder->geocode( > location => $near > ); > > my $latitude = $location->{BestLocation}->{Coordinates}->{Latitude}; > my $longitude = $location->{BestLocation}->{Coordinates}->{Longitude}; > > my %seen = (); > for( 1..10 ) { > > my $result = $twit->search( { geocode > => "$latitude,$longitude,$units", page => $_, rpp => 100 } );
There are 2 problems with this search. First, Twitter doesn't return results for just the geocode parameter, alone. You also need a "q" parameter. Second, the $units needs to include the number of units, not just the unit-of-measure. Try: ->search({ q => "pizza", geocode => "$latitude,$longitude,25$units", rpp => 100 }); There's also a Twitter bug here, in my opinion. Rather than returning an error in JSON, Twitter is returning a 500 response code and an unhelpful HTML page. You should consider using Net::Twitter, rather than Net::Twitter::Search. The latter is really for backwards compatibility with the original Net::Search module before the Search API was integrated into Net::Twitter. Net::Twitter throws exceptions on error rather than just returning undef, which would have made it more obvious that an error occurred rather than just a lack of results. use Net::Twitter; use Try::Tiny; $twit = Net::Twitter->new(traits => ['API::Search']); try { $result = $twit->search({ ... }); } catch { warn $_; # would have printed "Internal Server Error: 500" }; I'm going to leave this bug open while I consider what, if anything, to do with it. Better documentation would be helpful. I could do some parameter checking, but I have avoided that in the past so that as Twitter changes their API (adding, dropping, or changing parameter requirements), no code changes to Net::Twitter are required to accommodate them. Perhaps some diagnostics on failure. -Marc
Twitter seems to have fixed this issue on their end. -Marc


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.