r63248 - in /branches/upstream/libnet-twitter-perl/current: ./ lib/Net/ lib/Net/Twitter/ lib/Net/Twitter/Role/ lib/Net/Twitter/Role/API/ src/ t/
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Sun Oct 3 20:03:34 UTC 2010
Author: jawnsy-guest
Date: Sun Oct 3 20:03:13 2010
New Revision: 63248
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=63248
Log:
[svn-upgrade] new version libnet-twitter-perl (3.13009)
Added:
branches/upstream/libnet-twitter-perl/current/t/stack_trace.t
branches/upstream/libnet-twitter-perl/current/t/twitter_error.t
Modified:
branches/upstream/libnet-twitter-perl/current/Changes
branches/upstream/libnet-twitter-perl/current/MANIFEST
branches/upstream/libnet-twitter-perl/current/META.yml
branches/upstream/libnet-twitter-perl/current/Makefile.PL
branches/upstream/libnet-twitter-perl/current/README
branches/upstream/libnet-twitter-perl/current/lib/Net/Identica.pm
branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pm
branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pod
branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Core.pm
branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Error.pm
branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/OAuth.pm
branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/API/REST.pm
branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/API/TwitterVision.pm
branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/OAuth.pm
branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/WrapError.pm
branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Search.pm
branches/upstream/libnet-twitter-perl/current/src/net-twitter-pod.tt2
branches/upstream/libnet-twitter-perl/current/t/20_exceptions.t
Modified: branches/upstream/libnet-twitter-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/Changes?rev=63248&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/Changes (original)
+++ branches/upstream/libnet-twitter-perl/current/Changes Sun Oct 3 20:03:13 2010
@@ -1,3 +1,16 @@
+3.13009 2010-09-17
+ - use Athorization header for OAuth token requests rather than query params
+ - "identica => 1" sets OAuth URLs (assist from barbie)
+ - updated Synopsis with OAuth (closes RT#61273)
+
+3.13008_02 2010-09-04
+ - fixed stack frame filter
+ - fixed missing dependency
+ - detect Twitter's errors array as an error object
+
+3.13008_01 2010-08-31
+ - extract error from the various disparate error formats
+
3.13008 2010-08-26
- use HTTPS for all OAuth token negotiation steps
Modified: branches/upstream/libnet-twitter-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/MANIFEST?rev=63248&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/MANIFEST (original)
+++ branches/upstream/libnet-twitter-perl/current/MANIFEST Sun Oct 3 20:03:13 2010
@@ -66,4 +66,6 @@
t/lib/TestUA.pm
t/lookup_users.t
t/retry.t
+t/stack_trace.t
+t/twitter_error.t
t/unicode.t
Modified: branches/upstream/libnet-twitter-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/META.yml?rev=63248&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/META.yml (original)
+++ branches/upstream/libnet-twitter-perl/current/META.yml Sun Oct 3 20:03:13 2010
@@ -25,6 +25,7 @@
Data::Visitor::Callback: 0
DateTime: 0.51
DateTime::Format::Strptime: 1.09
+ Devel::StackTrace: 0
Digest::SHA: 0
Encode: 0
HTML::Entities: 0
@@ -40,7 +41,7 @@
Net::Netrc: 0
Net::OAuth: 0.25
Scalar::Util: 0
- Try::Tiny: 0
+ Try::Tiny: 0.03
URI: 1.4
URI::Escape: 0
namespace::autoclean: 0.09
@@ -50,4 +51,4 @@
homepage: http://github.com/semifor/Net-Twitter
license: http://dev.perl.org/licenses/
repository: git://github.com/semifor/Net-Twitter.git
-version: 3.13008
+version: 3.13009
Modified: branches/upstream/libnet-twitter-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/Makefile.PL?rev=63248&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/Makefile.PL (original)
+++ branches/upstream/libnet-twitter-perl/current/Makefile.PL Sun Oct 3 20:03:13 2010
@@ -22,6 +22,7 @@
requires 'Data::Visitor::Callback';
requires 'DateTime' => 0.51;
requires 'DateTime::Format::Strptime'=> 1.09;
+requires 'Devel::StackTrace';
requires 'Encode';
requires 'HTML::Entities';
requires 'HTTP::Request::Common';
@@ -35,7 +36,7 @@
requires 'Net::OAuth' => 0.25;
requires 'URI' => 1.40;
requires 'URI::Escape';
-requires 'Try::Tiny';
+requires 'Try::Tiny' => 0.03;
test_requires 'Test::More' => 0.88; # for done_testing
Modified: branches/upstream/libnet-twitter-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/README?rev=63248&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/README (original)
+++ branches/upstream/libnet-twitter-perl/current/README Sun Oct 3 20:03:13 2010
@@ -2,16 +2,22 @@
Net::Twitter - A perl interface to the Twitter API
VERSION
- This document describes Net::Twitter version 3.13008
+ This document describes Net::Twitter version 3.13009
SYNOPSIS
use Net::Twitter;
use Scalar::Util 'blessed';
+ # When no authentication is required:
+ my $nt = Net::Twitter->new(legacy => 0);
+
+ # As of 13-Aug-2010, Twitter requires OAuth for authenticated requests
my $nt = Net::Twitter->new(
- traits => [qw/API::REST/],
- username => $user,
- password => $password
+ traits => [qw/OAuth API::REST/],
+ consumer_key => $consumer_key,
+ consumer_secret => $consumer_secret,
+ access_token => $token,
+ access_token_secret => $token_secret,
);
my $result = $nt->update('Hello, world!');
@@ -32,8 +38,17 @@
DESCRIPTION
This module provides a perl interface to the Twitter APIs. See
- <http://apiwiki.twitter.com/Twitter-API-Documentation> for a full
- description of the Twitter APIs.
+ <http://dev.twitter.com/doc> for a full description of the Twitter APIs.
+
+NOTICE! BASIC AUTHENTICATION IS DEAD
+ As of 31-Aug-2010, Twitter no longer supports Basic Authentication.
+ OAuth is now required for authenticated requests. For more information,
+ please see
+ <http://github.com/semifor/Net-Twitter/wiki/Net::Twitter-and-the-death-o
+ f-Basic-Authentication>.
+
+ Other Twitter compatible services may still accept Basic Authentication,
+ so support for it remains in "Net::Twitter".
OMG! THE MOOSE!
Net::Twitter is Moose based. Moose provides some advantages, including
@@ -58,7 +73,7 @@
the returned data.
The Twitter API online documentation is located at
- <http://apiwiki.twitter.com/Twitter-API-Documentation>.
+ <http://dev.twitter.com/doc>.
To inspect the data, use Data::Dumper or similar module of your choice.
Here's a simple example using Data::Dumper:
@@ -185,15 +200,19 @@
Net::Twitter->new(traits => ['Legacy']);
username
- This is the screen name or email used to authenticate with
- Twitter.
+ This is the username for Basic Authentication. NOTE: as of
+ 31-Aug-2010, Twitter no longer supports Basic Authentication.
+ Use OAuth instead. Other Twitter compatible services may,
+ however, accept Basic Authentication, so support for it remains
+ in "Net::Twitter".
password
- This is the password used to authenticate with Twitter.
+ This is the password used for Basic Authentication.
clientname
The value for the "X-Twitter-Client-Name" HTTP header. It
- defaults to "Perl Net::Twitter".
+ defaults to "Perl Net::Twitter". Note: This option has nothing
+ to do with the "via" application byline.
clientver
The value for the "X-Twitter-Client-Version" HTTP header. It
@@ -220,19 +239,10 @@
version of "Net::Twitter".
source
- The value used in the "source" parameter of API method calls. It
- is currently only used in the "update" method in the REST API.
- It defaults to "twitterpm". This results in the text "from
- Net::Twitter" rather than "from web" for status messages posted
- from "Net::Twitter" when displayed via the Twitter web
- interface.
-
- Twitter is no longer registering source parameters. New
- applications should implement OAuth and register via
- <http://twitter.com/oauth_clients>.
-
- Only use the "source" parameter if you have an existing,
- registered source parameter from Twitter.
+ Twitter on longer uses the "source" parameter. Support for it
+ remains in "Net::Twitter" for any compatible services that may
+ use it. It was originally used by Twitter to provide an "via"
+ application byline.
apiurl
The URL for the Twitter API. This defaults to
@@ -300,18 +310,17 @@
by "Net::Twitter". Use it with caution.
AUTHENTICATION
- Twitter currently provides two authentication strategies: Basic
- Authentication and OAuth. OAuth is officially in beta, however, Twitter
- has expressed a desire to deprecate Basic Authentication in the future,
- so consider using OAuth in your applications.
-
- To set up Basic Authentication in "Net::Twitter", provide the "username"
- and "password" options to "new" or call the "credentials" method.
+ As of 31-Aug-2010, Twitter requires OAuth for authenticated requests.
+ Other Twitter compatible services, like Identi.ca, accept Basic
+ Authentication. So, "Net::Twitter" provides support for both.
To set up OAuth, include the "OAuth" trait and include the
"consumer_key" and "consumer_secret" options to "new". See
Net::Twitter::Role::OAuth for more information on using OAuth, including
examples.
+
+ To set up Basic Authentication in "Net::Twitter", provide the "username"
+ and "password" options to "new" or call the "credentials" method.
In addition to the arguments specified for each API method described
below, an additional "authenticate" parameter can be passed. To request
@@ -1772,7 +1781,7 @@
Net::Twitter::Error
The "Net::Twitter" exception object.
- <http://apiwiki.twitter.com/Twitter-API-Documentation>
+ <http://dev.twitter.com/doc>
This is the official Twitter API documentation. It describes the
methods and their parameters in more detail and may be more current
than the documentation provided with this module.
Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Identica.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Identica.pm?rev=63248&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Identica.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Identica.pm Sun Oct 3 20:03:13 2010
@@ -2,7 +2,7 @@
use Moose;
# use *all* digits for fBSD ports
-our $VERSION = '3.13008';
+our $VERSION = '3.13009';
$VERSION = eval $VERSION; # numify for warning-free dev releases
extends 'Net::Twitter::Core';
Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pm?rev=63248&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pm Sun Oct 3 20:03:13 2010
@@ -11,7 +11,7 @@
);
# use *all* digits for fBSD ports
-our $VERSION = '3.13008';
+our $VERSION = '3.13009';
$VERSION = eval $VERSION; # numify for warning-free dev releases
Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pod
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pod?rev=63248&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pod (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pod Sun Oct 3 20:03:13 2010
@@ -4,17 +4,23 @@
=head1 VERSION
-This document describes Net::Twitter version 3.13008
+This document describes Net::Twitter version 3.13009
=head1 SYNOPSIS
use Net::Twitter;
use Scalar::Util 'blessed';
+ # When no authentication is required:
+ my $nt = Net::Twitter->new(legacy => 0);
+
+ # As of 13-Aug-2010, Twitter requires OAuth for authenticated requests
my $nt = Net::Twitter->new(
- traits => [qw/API::REST/],
- username => $user,
- password => $password
+ traits => [qw/OAuth API::REST/],
+ consumer_key => $consumer_key,
+ consumer_secret => $consumer_secret,
+ access_token => $token,
+ access_token_secret => $token_secret,
);
my $result = $nt->update('Hello, world!');
@@ -37,8 +43,16 @@
=head1 DESCRIPTION
This module provides a perl interface to the Twitter APIs. See
-L<http://apiwiki.twitter.com/Twitter-API-Documentation> for a full description
-of the Twitter APIs.
+L<http://dev.twitter.com/doc> for a full description of the Twitter APIs.
+
+=head1 NOTICE! BASIC AUTHENTICATION IS DEAD
+
+As of 31-Aug-2010, Twitter no longer supports Basic Authentication. OAuth is
+now required for authenticated requests. For more information, please see
+L<http://github.com/semifor/Net-Twitter/wiki/Net::Twitter-and-the-death-of-Basic-Authentication>.
+
+Other Twitter compatible services may still accept Basic Authentication, so
+support for it remains in C<Net::Twitter>.
=head1 OMG! THE MOOSE!
@@ -65,7 +79,7 @@
returned data.
The Twitter API online documentation is located at
-L<http://apiwiki.twitter.com/Twitter-API-Documentation>.
+L<http://dev.twitter.com/doc>.
To inspect the data, use L<Data::Dumper> or similar module of your choice.
Here's a simple example using Data::Dumper:
@@ -204,16 +218,20 @@
=item username
-This is the screen name or email used to authenticate with Twitter.
+This is the username for Basic Authentication. NOTE: as of 31-Aug-2010,
+Twitter no longer supports Basic Authentication. Use OAuth instead. Other
+Twitter compatible services may, however, accept Basic Authentication, so
+support for it remains in C<Net::Twitter>.
=item password
-This is the password used to authenticate with Twitter.
+This is the password used for Basic Authentication.
=item clientname
The value for the C<X-Twitter-Client-Name> HTTP header. It defaults to "Perl
-Net::Twitter".
+Net::Twitter". Note: This option has nothing to do with the "via" application
+byline.
=item clientver
@@ -244,17 +262,9 @@
=item source
-The value used in the C<source> parameter of API method calls. It is currently
-only used in the C<update> method in the REST API. It defaults to
-"twitterpm". This results in the text "from Net::Twitter" rather than "from
-web" for status messages posted from C<Net::Twitter> when displayed via the
-Twitter web interface.
-
-Twitter is no longer registering source parameters. New applications should
-implement OAuth and register via L<http://twitter.com/oauth_clients>.
-
-Only use the C<source> parameter if you have an existing, registered source
-parameter from Twitter.
+Twitter on longer uses the C<source> parameter. Support for it remains in
+C<Net::Twitter> for any compatible services that may use it. It was
+originally used by Twitter to provide an "via" application byline.
=item apiurl
@@ -336,17 +346,16 @@
=head1 AUTHENTICATION
-Twitter currently provides two authentication strategies: Basic Authentication and
-OAuth. OAuth is officially in beta, however, Twitter has expressed a desire to
-deprecate Basic Authentication in the future, so consider using OAuth in your
-applications.
-
-To set up Basic Authentication in C<Net::Twitter>, provide the C<username> and
-C<password> options to L</new> or call the L</credentials> method.
+As of 31-Aug-2010, Twitter requires OAuth for authenticated requests. Other
+Twitter compatible services, like Identi.ca, accept Basic Authentication. So,
+C<Net::Twitter> provides support for both.
To set up OAuth, include the C<OAuth> trait and include the C<consumer_key> and
C<consumer_secret> options to L</new>. See L<Net::Twitter::Role::OAuth> for
more information on using OAuth, including examples.
+
+To set up Basic Authentication in C<Net::Twitter>, provide the C<username> and
+C<password> options to L</new> or call the L</credentials> method.
In addition to the arguments specified for each API method described below, an
additional C<authenticate> parameter can be passed. To request an
@@ -2575,7 +2584,7 @@
The C<Net::Twitter> exception object.
-=item L<http://apiwiki.twitter.com/Twitter-API-Documentation>
+=item L<http://dev.twitter.com/doc>
This is the official Twitter API documentation. It describes the methods and their
parameters in more detail and may be more current than the documentation provided
Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Core.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Core.pm?rev=63248&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Core.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Core.pm Sun Oct 3 20:03:13 2010
@@ -13,11 +13,12 @@
use Encode qw/encode_utf8/;
use DateTime;
use Data::Visitor::Callback;
+use Try::Tiny;
use namespace::autoclean;
# use *all* digits for fBSD ports
-our $VERSION = '3.13008';
+our $VERSION = '3.13009';
$VERSION = eval $VERSION; # numify for warning-free dev releases
@@ -191,7 +192,7 @@
my $content = $res->content;
$content =~ s/^"(true|false)"$/$1/;
- my $obj = eval { $self->_from_json($content) };
+ my $obj = try { $self->_from_json($content) };
$self->_decode_html_entities($obj) if $obj && $self->decode_html_entities;
# filter before inflating objects
@@ -203,7 +204,7 @@
$self->_inflate_objects($datetime_parser, $obj);
# Twitter sometimes returns an error with status code 200
- if ( ref $obj && reftype $obj eq 'HASH' && exists $obj->{error} ) {
+ if ( ref $obj && reftype $obj eq 'HASH' && (exists $obj->{error} || exists $obj->{errors}) ) {
die Net::Twitter::Error->new(twitter_error => $obj, http_response => $res);
}
Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Error.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Error.pm?rev=63248&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Error.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Error.pm Sun Oct 3 20:03:13 2010
@@ -1,24 +1,60 @@
package Net::Twitter::Error;
use Moose;
+use Try::Tiny;
+use Devel::StackTrace;
-use overload '""' => \&error,,
+use overload '""' => \&error,
'fallback' => 1;
-has twitter_error => ( isa => 'HashRef|Object', is => 'rw', predicate => 'has_twitter_error' );
+has twitter_error => ( is => 'rw', predicate => 'has_twitter_error' );
has http_response => ( isa => 'HTTP::Response', is => 'rw', required => 1, handles => [qw/code message/] );
+has stack_trace => ( is => 'ro', init_arg => undef, builder => '_build_stack_trace' );
+has _stringified => ( is => 'rw', init_arg => undef, default => undef );
+
+sub _build_stack_trace {
+ my $seen;
+ my $this_sub = (caller 0)[3];
+ Devel::StackTrace->new(frame_filter => sub {
+ my $caller = shift->{caller};
+ my $in_nt = $caller->[0] =~ /^Net::Twitter::/ || $caller->[3] eq $this_sub;
+ ($seen ||= $in_nt) && !$in_nt || 0;
+ });
+}
sub error {
my $self = shift;
- # We MUST stringyfy to something that evaluates to true, or testing $@ will fail!
- $self->has_twitter_error && $self->twitter_error->{error}
- || ( $self->message . ": " . $self->code )
- || '[unknown]';
+ return $self->_stringified if $self->_stringified;
+
+ # Don't walk on $@
+ local $@;
+
+ # Twitter does not return a consintent error structure, so we have to
+ # try each known (or guessed) variant to find a suitable message...
+ my $error = $self->has_twitter_error && do {
+ my $e = $self->twitter_error;
+
+ # the newest: array of errors
+ try { exists $e->{errors} && exists $e->{errors}[0] && exists $e->{errors}[0]{message}
+ && $e->{errors}[0]{message} }
+
+ # it's single error variant
+ || try { exists $e->{error} && exists $e->{error}{message} && $e->{error}{message} }
+
+ # or maybe it's not that deep (documentation would be helpful, here, Twitter!)
+ || try { exists $e->{message} && $e->{message} }
+
+ # the original error structure
+ || try { exists $e->{error} && $e->{error} }
+ } || $self->http_response->status_line;
+
+ my ($location) = $self->stack_trace->frame(0)->as_string =~ /( at .*)/;
+ return $self->_stringified($error . ($location || ''));
}
+__PACKAGE__->meta->make_immutable;
+
no Moose;
-
-__PACKAGE__->meta->make_immutable;
1;
Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/OAuth.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/OAuth.pm?rev=63248&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/OAuth.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/OAuth.pm Sun Oct 3 20:03:13 2010
@@ -2,7 +2,7 @@
use Moose;
# use *all* digits for fBSD ports
-our $VERSION = '3.13008';
+our $VERSION = '3.13009';
$VERSION = eval $VERSION; # numify for warning-free dev releases
extends 'Net::Twitter::Core';
Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/API/REST.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/API/REST.pm?rev=63248&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/API/REST.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/API/REST.pm Sun Oct 3 20:03:13 2010
@@ -30,17 +30,18 @@
%options = (
apiurl => 'http://identi.ca/api',
apirealm => 'Laconica API',
+ oauth_urls => {
+ request_token_url => "https://identi.ca/api/oauth/request_token",
+ authentication_url => "https://identi.ca/api/oauth/authenticate",
+ authorization_url => "https://identi.ca/api/oauth/authorize",
+ access_token_url => "https://identi.ca/api/oauth/access_token",
+ xauth_url => "https://identi.ca/api/oauth/access_token",
+ },
%options,
);
}
return $next->($class, \%options);
-};
-
-after credentials => sub {
- my $self = shift;
-
- $self->ua->credentials($self->apihost, $self->apirealm, $self->username, $self->password);
};
base_url 'apiurl';
Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/API/TwitterVision.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/API/TwitterVision.pm?rev=63248&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/API/TwitterVision.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/API/TwitterVision.pm Sun Oct 3 20:03:13 2010
@@ -10,12 +10,6 @@
has tvrealm => ( isa => 'Str', is => 'ro', default => 'Web Password' );
requires qw/ua username password/;
-
-after credentials => sub {
- my $self = shift;
-
- $self->ua->credentials($self->tvhost, $self->tvrealm, $self->username, $self->password);
-};
base_url 'tvurl';
authenticate 1;
Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/OAuth.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/OAuth.pm?rev=63248&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/OAuth.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/OAuth.pm Sun Oct 3 20:03:13 2010
@@ -107,8 +107,11 @@
%params,
);
- my $res = $self->ua->get($request->to_url);
- die "GET $uri failed: ".$res->status_line
+ my $msg = HTTP::Request->new(GET => $uri);
+ $msg->header(authorization => $request->to_authorization_header);
+
+ my $res = $self->_send_request($msg);
+ croak "GET $uri failed: ".$res->status_line
unless $res->is_success;
# reuse $uri to extract parameters from the response content
@@ -132,8 +135,11 @@
%params, # verifier => $verifier
);
- my $res = $self->ua->get($request->to_url);
- die "GET $uri failed: ".$res->status_line
+ my $msg = HTTP::Request->new(GET => $uri);
+ $msg->header(authorization => $request->to_authorization_header);
+
+ my $res = $self->_send_request($msg);
+ croak "GET $uri failed: ".$res->status_line
unless $res->is_success;
# discard request tokens, they're no longer valid
Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/WrapError.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/WrapError.pm?rev=63248&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/WrapError.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/WrapError.pm Sun Oct 3 20:03:13 2010
@@ -1,5 +1,7 @@
package Net::Twitter::Role::WrapError;
use Moose::Role;
+use Try::Tiny;
+use Scalar::Util qw/blessed/;
requires qw/_parse_result/;
@@ -30,12 +32,13 @@
$self->_clear_error;
$self->_http_response($res);
- my $r = eval { $next->($self, $res, $sythetic_args, $datetime_parser) };
- if ( $@ ) {
- die $@ unless UNIVERSAL::isa($@, 'Net::Twitter::Error');
+ my $r = try { $next->($self, $res, $sythetic_args, $datetime_parser) }
+ catch {
+ $DB::single = 1;
+ die $_ unless blessed $_ && $_->isa('Net::Twitter::Error');
- $self->_twitter_error($@->has_twitter_error
- ? $@->twitter_error
+ $self->_twitter_error($_->has_twitter_error
+ ? $_->twitter_error
: $self->_inflate_objects(
$datetime_parser,
{
@@ -44,8 +47,8 @@
}
)
);
- $r = $self->_error_return_val;
- }
+ return $self->_error_return_val;
+ };
return $r;
};
Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Search.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Search.pm?rev=63248&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Search.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Search.pm Sun Oct 3 20:03:13 2010
@@ -2,7 +2,7 @@
use Moose;
# use *all* digits for fBSD ports
-our $VERSION = '3.13008';
+our $VERSION = '3.13009';
$VERSION = eval $VERSION; # numify for warning-free dev releases
extends 'Net::Twitter::Core';
Modified: branches/upstream/libnet-twitter-perl/current/src/net-twitter-pod.tt2
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/src/net-twitter-pod.tt2?rev=63248&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/src/net-twitter-pod.tt2 (original)
+++ branches/upstream/libnet-twitter-perl/current/src/net-twitter-pod.tt2 Sun Oct 3 20:03:13 2010
@@ -11,10 +11,16 @@
use Net::Twitter;
use Scalar::Util 'blessed';
+ # When no authentication is required:
+ my $nt = Net::Twitter->new(legacy => 0);
+
+ # As of 13-Aug-2010, Twitter requires OAuth for authenticated requests
my $nt = Net::Twitter->new(
- traits => [qw/API::REST/],
- username => $user,
- password => $password
+ traits => [qw/OAuth API::REST/],
+ consumer_key => $consumer_key,
+ consumer_secret => $consumer_secret,
+ access_token => $token,
+ access_token_secret => $token_secret,
);
my $result = $nt->update('Hello, world!');
@@ -37,8 +43,16 @@
=head1 DESCRIPTION
This module provides a perl interface to the Twitter APIs. See
-L<http://apiwiki.twitter.com/Twitter-API-Documentation> for a full description
-of the Twitter APIs.
+L<http://dev.twitter.com/doc> for a full description of the Twitter APIs.
+
+=head1 NOTICE! BASIC AUTHENTICATION IS DEAD
+
+As of 31-Aug-2010, Twitter no longer supports Basic Authentication. OAuth is
+now required for authenticated requests. For more information, please see
+L<http://github.com/semifor/Net-Twitter/wiki/Net::Twitter-and-the-death-of-Basic-Authentication>.
+
+Other Twitter compatible services may still accept Basic Authentication, so
+support for it remains in C<Net::Twitter>.
=head1 OMG! THE MOOSE!
@@ -65,7 +79,7 @@
returned data.
The Twitter API online documentation is located at
-L<http://apiwiki.twitter.com/Twitter-API-Documentation>.
+L<http://dev.twitter.com/doc>.
To inspect the data, use L<Data::Dumper> or similar module of your choice.
Here's a simple example using Data::Dumper:
@@ -204,16 +218,20 @@
=item username
-This is the screen name or email used to authenticate with Twitter.
+This is the username for Basic Authentication. NOTE: as of 31-Aug-2010,
+Twitter no longer supports Basic Authentication. Use OAuth instead. Other
+Twitter compatible services may, however, accept Basic Authentication, so
+support for it remains in C<Net::Twitter>.
=item password
-This is the password used to authenticate with Twitter.
+This is the password used for Basic Authentication.
=item clientname
The value for the C<X-Twitter-Client-Name> HTTP header. It defaults to "Perl
-Net::Twitter".
+Net::Twitter". Note: This option has nothing to do with the "via" application
+byline.
=item clientver
@@ -244,17 +262,9 @@
=item source
-The value used in the C<source> parameter of API method calls. It is currently
-only used in the C<update> method in the REST API. It defaults to
-"twitterpm". This results in the text "from Net::Twitter" rather than "from
-web" for status messages posted from C<Net::Twitter> when displayed via the
-Twitter web interface.
-
-Twitter is no longer registering source parameters. New applications should
-implement OAuth and register via L<http://twitter.com/oauth_clients>.
-
-Only use the C<source> parameter if you have an existing, registered source
-parameter from Twitter.
+Twitter on longer uses the C<source> parameter. Support for it remains in
+C<Net::Twitter> for any compatible services that may use it. It was
+originally used by Twitter to provide an "via" application byline.
=item apiurl
@@ -336,17 +346,16 @@
=head1 AUTHENTICATION
-Twitter currently provides two authentication strategies: Basic Authentication and
-OAuth. OAuth is officially in beta, however, Twitter has expressed a desire to
-deprecate Basic Authentication in the future, so consider using OAuth in your
-applications.
-
-To set up Basic Authentication in C<Net::Twitter>, provide the C<username> and
-C<password> options to L</new> or call the L</credentials> method.
+As of 31-Aug-2010, Twitter requires OAuth for authenticated requests. Other
+Twitter compatible services, like Identi.ca, accept Basic Authentication. So,
+C<Net::Twitter> provides support for both.
To set up OAuth, include the C<OAuth> trait and include the C<consumer_key> and
C<consumer_secret> options to L</new>. See L<Net::Twitter::Role::OAuth> for
more information on using OAuth, including examples.
+
+To set up Basic Authentication in C<Net::Twitter>, provide the C<username> and
+C<password> options to L</new> or call the L</credentials> method.
In addition to the arguments specified for each API method described below, an
additional C<authenticate> parameter can be passed. To request an
@@ -686,7 +695,7 @@
The C<Net::Twitter> exception object.
-=item L<http://apiwiki.twitter.com/Twitter-API-Documentation>
+=item L<http://dev.twitter.com/doc>
This is the official Twitter API documentation. It describes the methods and their
parameters in more detail and may be more current than the documentation provided
Modified: branches/upstream/libnet-twitter-perl/current/t/20_exceptions.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/t/20_exceptions.t?rev=63248&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/t/20_exceptions.t (original)
+++ branches/upstream/libnet-twitter-perl/current/t/20_exceptions.t Sun Oct 3 20:03:13 2010
@@ -9,7 +9,7 @@
eval 'use TestUA';
plan skip_all => 'LWP::UserAgent 5.819 required for tests' if $@;
-plan tests => 10;
+plan tests => 11;
my $nt = Net::Twitter->new(
traits => [qw/API::REST/],
@@ -25,6 +25,15 @@
error => 'No direct message with that ID found.',
}));
$t->response($response);
+
+eval { $nt->destroy_direct_message(456) };
+my $message = '$@ valid after stringification';
+if( $@ ) {
+ ok $@, $message;
+}
+else {
+ fail $message;
+}
dies_ok { $nt->destroy_direct_message(456) } 'TwitterException';
my $e = $@;
Added: branches/upstream/libnet-twitter-perl/current/t/stack_trace.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/t/stack_trace.t?rev=63248&op=file
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/t/stack_trace.t (added)
+++ branches/upstream/libnet-twitter-perl/current/t/stack_trace.t Sun Oct 3 20:03:13 2010
@@ -1,0 +1,45 @@
+#!perl
+use warnings;
+use strict;
+use Test::More tests => 4;
+
+{
+ package Foo;
+ use Moose;
+
+ has net_twitter => is => 'rw', required => 1;
+
+ sub whois {
+ my ( $self, $id ) = @_;
+
+ # $line follows, should be reported as frame 0 in the stack trace
+ $self->net_twitter->show_user($id);
+ }
+}
+
+my $line = __LINE__ - 4; # is there a better way to do this?
+
+use Net::Twitter;
+use HTTP::Response;
+use Try::Tiny;
+
+my $nt = Net::Twitter->new(legacy => 0);
+
+$nt->ua->add_handler(request_send => sub {
+ my $res = HTTP::Response->new(403);
+ $res->content('{"errors":[{"code":63,"message":"User has been suspended"}]}');
+ $res;
+});
+
+
+my $foo = Foo->new(net_twitter => $nt);
+try { $foo->whois(1234) }
+catch {
+ like $_->error, qr/suspended/, 'stringified error contains twitter error message';
+
+ my $frame = $_->stack_trace->frame(0);
+ my $file = __FILE__;
+ is $frame->{filename}, $file, "first stack frame file";
+ is $frame->{line}, $line, "first stack frame line";
+ like $_->error, qr( at $file line $line$), 'error contains first stack frame';
+};
Added: branches/upstream/libnet-twitter-perl/current/t/twitter_error.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/t/twitter_error.t?rev=63248&op=file
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/t/twitter_error.t (added)
+++ branches/upstream/libnet-twitter-perl/current/t/twitter_error.t Sun Oct 3 20:03:13 2010
@@ -1,0 +1,53 @@
+#!perl
+use warnings;
+use strict;
+use Test::More tests => 4;
+use Net::Twitter::Error;
+use HTTP::Response;
+
+{
+ # old school error
+ my $res = HTTP::Response->new(400);
+
+ my $e = Net::Twitter::Error->new(
+ http_response => $res,
+ twitter_error => { error => "Something wicked" },
+ );
+
+ like $e, qr/Something wicked/, 'old school twitter error';
+}
+
+{
+ # newer variant
+ my $res = HTTP::Response->new(400);
+
+ my $e = Net::Twitter::Error->new(
+ http_response => $res,
+ twitter_error => { error => { message => "Something wicked" } },
+ );
+
+ like $e, qr/Something wicked/, 'twitter error with message/code';
+}
+
+{
+ # array of errors variant
+ my $res = HTTP::Response->new(400);
+
+ my $e = Net::Twitter::Error->new(
+ http_response => $res,
+ twitter_error => { errors => [{ message => "Something wicked" }] },
+ );
+
+ like $e, qr/Something wicked/, 'twitter array of errors';
+}
+
+{
+ # unexpected
+ my $res = HTTP::Response->new(400);
+
+ my $e = Net::Twitter::Error->new(
+ http_response => $res,
+ );
+
+ like $e, qr/Bad Request/, 'twitter array of errors';
+}
More information about the Pkg-perl-cvs-commits
mailing list