r53427 - in /branches/upstream/libnet-twitter-perl/current: ./ lib/Net/ lib/Net/Twitter/ lib/Net/Twitter/OAuth/ lib/Net/Twitter/Role/ src/ t/

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Sun Feb 28 20:22:33 UTC 2010


Author: jawnsy-guest
Date: Sun Feb 28 20:22:20 2010
New Revision: 53427

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=53427
Log:
[svn-upgrade] Integrating new upstream version, libnet-twitter-perl (3.11007)

Added:
    branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/OAuth/
    branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/OAuth/XAuthRequest.pm
    branches/upstream/libnet-twitter-perl/current/t/unicode.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/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/API.pm
    branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Core.pm
    branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/OAuth.pm
    branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/OAuth.pm
    branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/RateLimit.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/02_fails.t
    branches/upstream/libnet-twitter-perl/current/t/10_net-twitter-regression.t
    branches/upstream/libnet-twitter-perl/current/t/51_since.t
    branches/upstream/libnet-twitter-perl/current/t/99-pod_spelling.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=53427&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/Changes (original)
+++ branches/upstream/libnet-twitter-perl/current/Changes Sun Feb 28 20:22:20 2010
@@ -1,17 +1,33 @@
-3.11004 2009-02-09
+3.11007 2010-02-27
+    - xAuth implemented and tested
+
+3.11006_01 2010-02-26
+    - xAuth implemented: @oauth = $nt->xauth($username, $password);
+
+3.11006 2010-02-25
+    - Fixed: unicode.t skip needed number of tests to skip (miyagawa)
+
+3.11005 2010-02-25
+    - Fixed: image updates accept a single array ref argument (RT#54422)
+    - Fixed: "since" synthetic arg with InflateObjects role (RT#54901)
+    - Fixed: utf8 encoding error for latin1 using Basic Authentication
+    - Allow a pre-created user agent object as argument to new (ua => $ua)
+    - FAQ: How do I get Twitter to display something other than "from Perl Net::Twitter"?
+
+3.11004 2010-02-09
     - Removed an extraneous tar ball from the distribution (no code changes)
 
-3.11003 2009-01-29
+3.11003 2010-01-29
     - Renamed "retweeted_of_me" REST API call to the correct "retweets_of_me" (Dan Moore @mgrdcm)
     - Back the Moose requirement down to 0.09 (earliest version with native traits)
 
-3.11002 2009-01-28
+3.11002 2010-01-28
     - Use Moose 0.94 with native traits (resolves CPAN testers failing reports)
 
-3.11001 2009-01-28
+3.11001 2010-01-28
     - Honor synthetic args (authenticate and since) for Lists API calls
 
-3.11000 2009-01-27
+3.11000 2010-01-27
     - Lists API overhaul; bug fixes, added parameters, documentation
     - Create meaninful names for anonymous classes; better error context
     - Added "Paging and Cursors" documentation section

Modified: branches/upstream/libnet-twitter-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/MANIFEST?rev=53427&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/MANIFEST (original)
+++ branches/upstream/libnet-twitter-perl/current/MANIFEST Sun Feb 28 20:22:20 2010
@@ -21,6 +21,7 @@
 lib/Net/Twitter/Core.pm
 lib/Net/Twitter/Error.pm
 lib/Net/Twitter/OAuth.pm
+lib/Net/Twitter/OAuth/XAuthRequest.pm
 lib/Net/Twitter/Role/API/Lists.pm
 lib/Net/Twitter/Role/API/REST.pm
 lib/Net/Twitter/Role/API/Search.pm
@@ -60,3 +61,4 @@
 t/99-pod_spelling.t
 t/99-pod_syntax.t
 t/lib/TestUA.pm
+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=53427&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/META.yml (original)
+++ branches/upstream/libnet-twitter-perl/current/META.yml Sun Feb 28 20:22:20 2010
@@ -50,4 +50,4 @@
   homepage: http://github.com/semifor/Net-Twitter
   license: http://dev.perl.org/licenses/
   repository: git://github.com/semifor/Net-Twitter.git
-version: 3.11004
+version: 3.11007

Modified: branches/upstream/libnet-twitter-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/README?rev=53427&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/README (original)
+++ branches/upstream/libnet-twitter-perl/current/README Sun Feb 28 20:22:20 2010
@@ -2,7 +2,7 @@
     Net::Twitter - A perl interface to the Twitter API
 
 VERSION
-    This document describes Net::Twitter version 3.11004
+    This document describes Net::Twitter version 3.11007
 
 SYNOPSIS
       use Net::Twitter;
@@ -1396,6 +1396,27 @@
 
             $r = $nt->search({ geocode => "45.511795,-122.675629,25mi" });
 
+    How do I get Twitter to display something other than "from Perl
+    Net::Twitter"?
+        If you set the source parameter to "api", twitter will display "from
+        API", and if you set it to the empty string, twitter will display,
+        "from web".
+
+            $nt = Net::Twitter->new(netrc => 1,legacy => 0,ssl => 1,source => 'api');
+            $nt->update('A post with the source parameter overridden.');
+            # result: http://twitter.com/semifor_test/status/6541105458
+
+            $nt = Net::Twitter->new(netrc => 1,legacy => 0,ssl => 1,source => '');
+            $nt->update('A post with the source parameter overridden.');
+            # result: http://twitter.com/semifor_test/status/6541257224
+
+        If you want something other than "Net::Twitter", "API", or "web",
+        you need to register an application and use OAuth authentication. If
+        you do that, you can have any name you choose for the application
+        printed as the source. Since rolling out OAuth, Twitter has stopped
+        issuing new registered source parameters, only existing register
+        source parameters are valid.
+
 SEE ALSO
     Net::Twitter::Error
         The "Net::Twitter" exception object.

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=53427&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Identica.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Identica.pm Sun Feb 28 20:22:20 2010
@@ -2,7 +2,7 @@
 use Moose;
 
 # use *all* digits for fBSD ports
-our $VERSION = '3.11004';
+our $VERSION = '3.11007';
 $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=53427&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pm Sun Feb 28 20:22:20 2010
@@ -11,7 +11,7 @@
 );
 
 # use *all* digits for fBSD ports
-our $VERSION = '3.11004';
+our $VERSION = '3.11007';
 
 $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=53427&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pod (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter.pod Sun Feb 28 20:22:20 2010
@@ -4,7 +4,7 @@
 
 =head1 VERSION
 
-This document describes Net::Twitter version 3.11004
+This document describes Net::Twitter version 3.11007
 
 =head1 SYNOPSIS
 
@@ -1963,6 +1963,26 @@
 
     $r = $nt->search({ geocode => "45.511795,-122.675629,25mi" });
 
+=item How do I get Twitter to display something other than "from Perl Net::Twitter"?
+
+If you set the source parameter to C<api>, twitter will display "from
+API", and if you set it to the empty string, twitter will display, "from
+web".
+
+    $nt = Net::Twitter->new(netrc => 1,legacy => 0,ssl => 1,source => 'api');
+    $nt->update('A post with the source parameter overridden.');
+    # result: http://twitter.com/semifor_test/status/6541105458
+
+    $nt = Net::Twitter->new(netrc => 1,legacy => 0,ssl => 1,source => '');
+    $nt->update('A post with the source parameter overridden.');
+    # result: http://twitter.com/semifor_test/status/6541257224
+
+If you want something other than "Net::Twitter", "API", or "web", you need to
+register an application and use OAuth authentication.  If you do that, you
+can have any name you choose for the application printed as the source.
+Since rolling out OAuth, Twitter has stopped issuing new registered source
+parameters, only existing register source parameters are valid.
+
 =back
 
 =head1 SEE ALSO

Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/API.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/API.pm?rev=53427&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/API.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/API.pm Sun Feb 28 20:22:20 2010
@@ -56,7 +56,6 @@
         my $args = ref $_[-1] eq 'HASH' ? { %{pop @_} } : {};
 
         if ( @_ ) {
-            ref $_[$_] && croak "arg $_ must not be a reference" for 0..$#_;
             @_ == @$arg_names || croak "$name expected @{[ scalar @$arg_names ]} args";
             @{$args}{@$arg_names} = @_;
         }

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=53427&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 Feb 28 20:22:20 2010
@@ -17,7 +17,7 @@
 use namespace::autoclean;
 
 # use *all* digits for fBSD ports
-our $VERSION = '3.11004';
+our $VERSION = '3.11007';
 
 $VERSION = eval $VERSION; # numify for warning-free dev releases
 
@@ -35,7 +35,7 @@
 has decode_html_entities => ( isa => 'Bool', is => 'rw', default => 0 );
 has useragent       => ( isa => 'Str', is => 'ro', default => "Net::Twitter/$VERSION (Perl)" );
 has source          => ( isa => 'Str', is => 'ro', default => 'twitterpm' );
-has ua              => ( isa => 'Object', is => 'rw' );
+has ua              => ( isa => 'Object', is => 'rw', lazy => 1, builder => '_build_ua' );
 has clientname      => ( isa => 'Str', is => 'ro', default => 'Perl Net::Twitter' );
 has clientver       => ( isa => 'Str', is => 'ro', default => $VERSION );
 has clienturl       => ( isa => 'Str', is => 'ro', default => 'http://search.cpan.org/dist/Net-Twitter/' );
@@ -62,9 +62,6 @@
 sub BUILD {
     my $self = shift;
 
-    eval "use " . $self->useragent_class;
-    croak $@ if $@;
-
     if ( $self->has_netrc ) {
         require Net::Netrc;
 
@@ -78,13 +75,23 @@
         $self->password($pass);
     }
 
-    $self->ua($self->useragent_class->new(%{$self->useragent_args}));
-    $self->ua->agent($self->useragent);
-    $self->ua->default_header('X-Twitter-Client'         => $self->clientname);
-    $self->ua->default_header('X-Twitter-Client-Version' => $self->clientver);
-    $self->ua->default_header('X-Twitter-Client-URL'     => $self->clienturl);
-    $self->ua->env_proxy;
     $self->credentials($self->username, $self->password) if $self->has_username;
+}
+
+sub _build_ua {
+    my $self = shift;
+
+    eval "use " . $self->useragent_class;
+    croak $@ if $@;
+
+    my $ua = $self->useragent_class->new(%{$self->useragent_args});
+    $ua->agent($self->useragent);
+    $ua->default_header('X-Twitter-Client'         => $self->clientname);
+    $ua->default_header('X-Twitter-Client-Version' => $self->clientver);
+    $ua->default_header('X-Twitter-Client-URL'     => $self->clienturl);
+    $ua->env_proxy;
+
+    return $ua;
 }
 
 sub credentials {
@@ -100,10 +107,10 @@
     my ($self, $args) = @_;
 
     # Values need to be utf-8 encoded.  Because of a perl bug, exposed when
-    # client code does "use utf8", keys must also be encoded as well.
+    # client code does "use utf8", keys must also be encoded.
     # see: http://www.perlmonks.org/?node_id=668987
     # and: http://perl5.git.perl.org/perl.git/commit/eaf7a4d2
-    return { map { ref($_) ? $_ : encode_utf8 $_ } %$args };
+    return { map { utf8::upgrade($_) unless ref($_); $_ } %$args };
 }
 
 # Basic Auth, overridden by Role::OAuth, if included
@@ -248,7 +255,7 @@
     my ($self, $arrayref) = @_;
 
     my $e = $arrayref->[0] || return;
-    return unless ref $e eq 'HASH';
+    return unless ref $e && reftype $e eq 'HASH';
     return exists $e->{created_at} && exists $e->{text} && exists $e->{id};
 }
 

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=53427&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 Feb 28 20:22:20 2010
@@ -2,7 +2,7 @@
 use Moose;
 
 # use *all* digits for fBSD ports
-our $VERSION = '3.11004';
+our $VERSION = '3.11007';
 $VERSION = eval $VERSION; # numify for warning-free dev releases
 
 extends  'Net::Twitter::Core';

Added: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/OAuth/XAuthRequest.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/OAuth/XAuthRequest.pm?rev=53427&op=file
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/OAuth/XAuthRequest.pm (added)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/OAuth/XAuthRequest.pm Sun Feb 28 20:22:20 2010
@@ -1,0 +1,36 @@
+package Net::Twitter::OAuth::XAuthRequest;
+use warnings;
+use strict;
+use base 'Net::OAuth::Request';
+
+__PACKAGE__->add_extension_param_pattern(qr/x_auth_/);
+__PACKAGE__->add_required_message_params(qw/
+    x_auth_username
+    x_auth_password
+    x_auth_mode
+/);
+sub allow_extra_params {0}
+sub sign_message {1}
+
+=head1 NAME
+
+Net::Twitter::OAuth::XAuthRequest - An OAuth protocol request for Twitter xAuth
+
+=head1 SEE ALSO
+
+L<Net::OAuth>, L<http://oauth.net>
+
+=head1 AUTHOR
+
+Marc Mims C<marc at questright.com>
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2010 Marc Mims, all rights reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
+
+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=53427&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 Feb 28 20:22:20 2010
@@ -24,6 +24,7 @@
         authentication_url => "http://twitter.com/oauth/authenticate",
         authorization_url  => "http://twitter.com/oauth/authorize",
         access_token_url   => "http://twitter.com/oauth/access_token",
+        xauth_url          => "https://twitter.com/oauth/access_token",
     };
 
     return { %$oauth_urls, %$args };
@@ -33,7 +34,7 @@
 has consumer_secret => ( isa => 'Str', is => 'ro', required => 1 );
 
 # url attributes
-for my $attribute ( qw/authentication_url authorization_url request_token_url access_token_url/ ) {
+for my $attribute ( qw/authentication_url authorization_url request_token_url access_token_url xauth_url/ ) {
     has $attribute => (
         isa    => 'Str', is => 'rw', required => 1,
         # inflate urls to URI objects when read
@@ -77,7 +78,8 @@
 sub _make_oauth_request {
     my ($self, $type, %params) = @_;
 
-    my $request = Net::OAuth->request($type)->new(
+    my $class = $type =~ s/^\+// ? $type : Net::OAuth->request($type);
+    my $request = $class->new(
         version          => '1.0',
         consumer_key     => $self->{consumer_key},
         consumer_secret  => $self->{consumer_secret},
@@ -204,6 +206,35 @@
     return $self->ua->request($msg);
 };
 
+sub xauth {
+    my ( $self, $username, $password ) = @_;
+
+    require Net::Twitter::OAuth::XAuthRequest;
+    my $uri = $self->xauth_url;
+    my $request = $self->_make_oauth_request(
+        '+Net::Twitter::OAuth::XAuthRequest',
+        request_url     => $uri,
+        x_auth_username => $username,
+        x_auth_password => $password,
+        x_auth_mode     => 'client_auth',
+    );
+
+    my $res = $self->ua->get($request->to_url);
+    die "GET $uri failed: ".$res->status_line
+        unless $res->is_success;
+
+    # reuse $uri to extract parameters from content
+    $uri->query($res->content);
+    my %res_param = $uri->query_form;
+
+    return (
+        $self->access_token($res_param{oauth_token}),
+        $self->access_token_secret($res_param{oauth_token_secret}),
+        $res_param{user_id},
+        $res_param{screen_name},
+    );
+}
+
 # shortcuts defined in early releases
 # DEPRECATED
 
@@ -382,9 +413,17 @@
 
 The user must have authorized this app at the url given by C<get_authorization_url> first.
 
-Returns the access token and access token secret but also sets them internally
-so that after calling this method, you can immediately call API methods
-requiring authentication.
+Returns the access_token, access_token_secret, user_id, and screen_name in a
+list.  Also sets them internally so that after calling this method, you can
+immediately call API methods requiring authentication.
+
+=item xauth($username, $password)
+
+Exchanges the C<$username> and C<$password> for access tokens.  This method has
+the same return value as C<request_access_token>: access_token, access_token_secret,
+user_id, and screen_name in a list. Also, like C<request_access_token>, it sets
+the access_token and access_secret, internally, so you can immediately call API
+methods requiring authentication.
 
 =item get_authorization_url(callback => $callback_url)
 

Modified: branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/RateLimit.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/RateLimit.pm?rev=53427&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/RateLimit.pm (original)
+++ branches/upstream/libnet-twitter-perl/current/lib/Net/Twitter/Role/RateLimit.pm Sun Feb 28 20:22:20 2010
@@ -17,7 +17,7 @@
 
     #...later
 
-    sleep $nt->until_rate(1.0) || $minumum_wait;
+    sleep $nt->until_rate(1.0) || $minimum_wait;
 
 =head1 DESCRIPTION
 

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=53427&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 Feb 28 20:22:20 2010
@@ -2,7 +2,7 @@
 use Moose;
 
 # use *all* digits for fBSD ports
-our $VERSION = '3.11004';
+our $VERSION = '3.11007';
 $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=53427&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 Feb 28 20:22:20 2010
@@ -662,6 +662,26 @@
 separated with commas.
 
     $r = $nt->search({ geocode => "45.511795,-122.675629,25mi" });
+
+=item How do I get Twitter to display something other than "from Perl Net::Twitter"?
+
+If you set the source parameter to C<api>, twitter will display "from
+API", and if you set it to the empty string, twitter will display, "from
+web".
+
+    $nt = Net::Twitter->new(netrc => 1,legacy => 0,ssl => 1,source => 'api');
+    $nt->update('A post with the source parameter overridden.');
+    # result: http://twitter.com/semifor_test/status/6541105458
+
+    $nt = Net::Twitter->new(netrc => 1,legacy => 0,ssl => 1,source => '');
+    $nt->update('A post with the source parameter overridden.');
+    # result: http://twitter.com/semifor_test/status/6541257224
+
+If you want something other than "Net::Twitter", "API", or "web", you need to
+register an application and use OAuth authentication.  If you do that, you
+can have any name you choose for the application printed as the source.
+Since rolling out OAuth, Twitter has stopped issuing new registered source
+parameters, only existing register source parameters are valid.
 
 =back
 

Modified: branches/upstream/libnet-twitter-perl/current/t/02_fails.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/t/02_fails.t?rev=53427&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/t/02_fails.t (original)
+++ branches/upstream/libnet-twitter-perl/current/t/02_fails.t Sun Feb 28 20:22:20 2010
@@ -9,7 +9,7 @@
 eval 'use TestUA';
 plan skip_all => 'LWP::UserAgent 5.819 required for tests' if $@;
 
-plan tests => 4;
+plan tests => 2;
 
 my $nt = Net::Twitter->new(
     traits   => [qw/API::REST/],
@@ -22,10 +22,8 @@
 # things that should fail
 throws_ok { $nt->relationship_exists(qw/one two three/) } qr/expected 2 args/, 'too many args';
 throws_ok {
-    Net::Twitter->new(useragent_class => 'NoSuchModule::Test7701')
+    Net::Twitter->new(useragent_class => 'NoSuchModule::Test7701')->verify_credentials
 } qr/Can't locate NoSuchModule/, 'bad useragent_class';
-throws_ok { $nt->show_status([ 123 ]) } qr/must not be a reference/, 'wrong type';
-throws_ok { $nt->friends({ count => 30, page => 4 }, 'extra') }
         qr/must not be a reference/, 'extra args';
 
 exit 0;

Modified: branches/upstream/libnet-twitter-perl/current/t/10_net-twitter-regression.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/t/10_net-twitter-regression.t?rev=53427&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/t/10_net-twitter-regression.t (original)
+++ branches/upstream/libnet-twitter-perl/current/t/10_net-twitter-regression.t Sun Feb 28 20:22:20 2010
@@ -95,5 +95,8 @@
 ### v3.10001 ### netrc used $self->apiurl, which is only available via the API::REST trait
 lives_ok  { Net::Twitter->new(netrc => 1, traits => [qw/API::Lists/]) }
           'netrc with API::Lists lives';
+### v3.11004 ### single array ref arg to update_profile_image not proprerly handled
+$r  = $nt->update_profile_image([ undef, 'my_mug.jpg', Content_Type => 'image/jpeg', Content => '' ]);
+is    $t->request->content_type, 'multipart/form-data', 'multipart/form-data';
 
 done_testing

Modified: branches/upstream/libnet-twitter-perl/current/t/51_since.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/t/51_since.t?rev=53427&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/t/51_since.t (original)
+++ branches/upstream/libnet-twitter-perl/current/t/51_since.t Sun Feb 28 20:22:20 2010
@@ -11,7 +11,7 @@
 
 use_ok 'Net::Twitter';
 
-my $nt = Net::Twitter->new(traits => [qw/API::REST API::Search/]);
+my $nt = Net::Twitter->new(traits => [qw/API::REST API::Search RateLimit InflateObjects/]);
 
 my $datetime_parser = do {
     no warnings 'once';

Modified: branches/upstream/libnet-twitter-perl/current/t/99-pod_spelling.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/t/99-pod_spelling.t?rev=53427&op=diff
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/t/99-pod_spelling.t (original)
+++ branches/upstream/libnet-twitter-perl/current/t/99-pod_spelling.t Sun Feb 28 20:22:20 2010
@@ -99,3 +99,4 @@
 username
 WOEID
 woeid
+xAuth

Added: branches/upstream/libnet-twitter-perl/current/t/unicode.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-perl/current/t/unicode.t?rev=53427&op=file
==============================================================================
--- branches/upstream/libnet-twitter-perl/current/t/unicode.t (added)
+++ branches/upstream/libnet-twitter-perl/current/t/unicode.t Sun Feb 28 20:22:20 2010
@@ -1,0 +1,85 @@
+#!perl
+use warnings;
+use strict;
+use Try::Tiny;
+use Test::More tests => 9;
+use Encode qw/decode encode_utf8 decode_utf8/;
+use Net::Twitter;
+
+eval "use LWP::UserAgent 5.819";
+plan skip_all => 'LWP::UserAgent >= 5.819 required' if $@;
+
+my $req;
+my $ua = LWP::UserAgent->new;
+$ua->add_handler(request_send => sub {
+    $req = shift;
+    return HTTP::Response->new(200);
+});
+
+sub raw_sent_status {
+    my $uri = URI->new;
+    $uri->query($req->content);
+    my %params = $uri->query_form;
+    return $params{status};
+}
+
+sub sent_status { decode_utf8 raw_sent_status() }
+
+my $nt = Net::Twitter->new(
+    traits          => [qw/API::REST OAuth/],
+    consumer_key    => 'key',
+    consumer_secret => 'secret',
+    ua              => $ua,
+);
+$nt->access_token('token');
+$nt->access_token_secret('secret');
+
+# "Hello world!" in traditional Chinese if Google translate is correct
+my $status = "\x{4E16}\x{754C}\x{60A8}\x{597D}\x{FF01}";
+
+ok utf8::is_utf8($status), 'status parameter is decoded';
+
+try { $nt->update($status) };
+
+is sent_status(), $status, 'sent status matches update parameter';
+
+# ISO-8859-1
+my $latin1 = "\xabHello, world\xbb";
+
+ok !utf8::is_utf8($latin1), "latin-1 string is not utf8 internally";
+try { $nt->update($latin1) };
+is sent_status(), $latin1, "latin-1 matches";
+ok !utf8::is_utf8($latin1), "latin-1 not promoted to utf8";
+
+### Net::Twitter expects decoded characters, not encoded bytes
+### So, sending encoded utf8 to Net::Twitter will result in double
+### encoded data.
+
+SKIP: {
+    eval "use Encode::DoubleEncodedUTF8";
+    skip "requires Encode::DoubleEncodedUTF8", 2 if $@;
+
+    try { $nt->update(encode_utf8 $status) };
+
+    my $bytes = raw_sent_status();
+
+    isnt $bytes, encode_utf8($status), "encoded status does not match";
+    is   decode('utf-8-de', $bytes), $status, "double encoded";
+};
+
+############################################################
+# Basic Auth
+############################################################
+
+$nt = Net::Twitter->new(
+    legacy   => 0,
+    username => 'fred',
+    password => 'pebbles',
+    ua       => $ua,
+);
+
+try { $nt->update($status) };
+is sent_status(), $status, 'basic auth';
+
+try { $nt->update($latin1) };
+is sent_status(), $latin1, 'latin-1 basic auth';




More information about the Pkg-perl-cvs-commits mailing list