Subject: | user_timeline method doesn't work |
Some Twitter API's responses don't have "WWW-Authenticate" header, for
example user_timeline. It means LWP::UserAgent will fail to send
request with "authorization" header, because LWP::UA try to send
authorized request after get status 401 response with WWW-Authenticate
header.
Subject: | Net-Twitter.patch |
*** Twitter.pm.org Fri Oct 12 21:04:45 2007
--- Twitter.pm Fri Oct 12 21:06:46 2007
***************
*** 33,61 ****
$conf{twittervision} = '0' unless defined $conf{twittervision};
$conf{ua} = LWP::UserAgent->new();
! $conf{ua}->credentials($conf{apihost},
! $conf{apirealm},
! $conf{username},
! $conf{password}
! );
$conf{ua}->agent("Net::Twitter/$Net::Twitter::VERSION");
$conf{ua}->default_header( "X-Twitter-Client:" => $conf{clientname} );
$conf{ua}->default_header( "X-Twitter-Client-Version:" => $conf{clientver} );
$conf{ua}->default_header( "X-Twitter-Client-URL:" => $conf{clienturl} );
$conf{ua}->env_proxy();
if ($conf{twittervision}) {
$conf{tvua} = LWP::UserAgent->new();
! $conf{tvua}->credentials($conf{tvhost},
! $conf{tvrealm},
! $conf{username},
! $conf{password}
! );
$conf{tvua}->agent("Net::Twitter/$Net::Twitter::VERSION");
$conf{tvua}->default_header( "X-Twitter-Client:" => $conf{clientname} );
$conf{tvua}->default_header( "X-Twitter-Client-Version:" => $conf{clientver} );
$conf{tvua}->default_header( "X-Twitter-Client-URL:" => $conf{clienturl} );
$conf{tvua}->env_proxy();
}
--- 33,63 ----
$conf{twittervision} = '0' unless defined $conf{twittervision};
$conf{ua} = LWP::UserAgent->new();
! #$conf{ua}->credentials($conf{apihost},
! # $conf{apirealm},
! # $conf{username},
! # $conf{password}
! # );
$conf{ua}->agent("Net::Twitter/$Net::Twitter::VERSION");
$conf{ua}->default_header( "X-Twitter-Client:" => $conf{clientname} );
$conf{ua}->default_header( "X-Twitter-Client-Version:" => $conf{clientver} );
$conf{ua}->default_header( "X-Twitter-Client-URL:" => $conf{clienturl} );
+ $conf{ua}->default_headers->authorization_basic($conf{username}, $conf{password});
$conf{ua}->env_proxy();
if ($conf{twittervision}) {
$conf{tvua} = LWP::UserAgent->new();
! #$conf{tvua}->credentials($conf{tvhost},
! # $conf{tvrealm},
! # $conf{username},
! # $conf{password}
! # );
$conf{tvua}->agent("Net::Twitter/$Net::Twitter::VERSION");
$conf{tvua}->default_header( "X-Twitter-Client:" => $conf{clientname} );
$conf{tvua}->default_header( "X-Twitter-Client-Version:" => $conf{clientver} );
$conf{tvua}->default_header( "X-Twitter-Client-URL:" => $conf{clienturl} );
+ $conf{tvua}->default_headers->authorization_basic($conf{username}, $conf{password});
$conf{tvua}->env_proxy();
}
***************
*** 69,79 ****
$apirealm ||= 'Twitter API';
$apihost ||= 'twitter.com:80';
! $self->{ua}->credentials($apihost,
! $apirealm,
! $username,
! $password
! );
}
--- 71,83 ----
$apirealm ||= 'Twitter API';
$apihost ||= 'twitter.com:80';
! #$self->{ua}->credentials($apihost,
! # $apirealm,
! # $username,
! # $password
! # );
!
! $self->{ua}->default_headers->authorization_basic($username, $password);
}