semifor/net-twitter-lite — Issue #5: NET::Twitter:Lite Twitter is over capacity problem
Author: RuZniki
Created: 2011-10-13 09:52:24+00:00
State: open

Hi.
I've find some problem with your module.
It happens when twiiter return http://twitter.com/503 error
You wait it wiil be in json, but it is html.
And api method return empty array.

I've find issue for twitter https://dev.twitter.com/issues/15
but until it will fix by twitter dev team, i've try to fix sub _parse_result (1682)
with adding (1689-1691)

sub _parse_result {
my ($self, $res) = @_;

# workaround for Laconica API returning bools as strings
# (Fixed in Laconi.ca 0.7.4)
my $content = $res->content;
$content =~ s/^"(true|false)"$/$1/;
if ($content =~ /\Twitter is over capacity.\<\/h2\>/) {
die Net::Twitter::Lite::Error->new(http_response => $res);
}
my $obj = $self->_from_json($content);

# Twitter sometimes returns an error with status code 200
if ( $obj && ref $obj eq 'HASH' && exists $obj->{error} ) {
die Net::Twitter::Lite::Error->new(twitter_error => $obj, http_response => $res);
}

return $obj if $res->is_success && defined $obj;

my $error = Net::Twitter::Lite::Error->new(http_response => $res);
$error->twitter_error($obj) if ref $obj;

die $error;
}

But