PerlのNet::TwitterをAPI v1.1に対応させる
- Net::Twitter - A perl interface to the Twitter API - metacpan.org
- Net::Twitter::Manual::MigratingToV1_1 - Migrating from Twitter API v1 to v1.1 - metacpan.org
Wherever you create a Net::Twitter object by calling new, replace trait API::REST with API::RESTv1_1. For most applications, that's all that is required.
Net::Twitter::Manual::MigratingToV1_1 - Migrating from Twitter API v1 to v1.1 - metacpan.org
やったー超簡単。と思ったら、こんなエラーが出る。
Conflict detected: Role Net::Twitter::Role::API::RESTv1_1 excludes role 'Net::Twitter::Role::API::Upload' at /usr/lib/perl5/site_perl/5.14/i686-cygwin-threads-64int/Moose/Meta/Role/Application/RoleSummation.pm line 88. Moose::Meta::Role::Application::RoleSummation::check_role_exclusions('Moose::Meta::Role::Application::RoleSummation=HASH(0x218a6040)', 'Moose::Meta::Role::Composite=HASH(0x21545e10)') called at /usr/lib/perl5/site_perl/5.14/i686-cygwin-threads-64int/Moose/Meta/Role/Application.pm line 54 Moose::Meta::Role::Application::apply('Moose::Meta::Role::Application::RoleSummation=HASH(0x218a6040)', 'Moose::Meta::Role::Composite=HASH(0x21545e10)') called at /usr/lib/perl5/site_perl/5.14/i686-cygwin-threads-64int/Moose/Meta/Role/Composite.pm line 132 Moose::Meta::Role::Composite::apply_params('Moose::Meta::Role::Composite=HASH(0x21545e10)', 'HASH(0x20a9b0a8)') called at /usr/lib/perl5/site_perl/5.14/i686-cygwin-threads-64int/Moose/Meta/Role.pm line 496 Moose::Meta::Role::combine('Moose::Meta::Role', 'ARRAY(0x215af958)', 'ARRAY(0x2157c4e8)', 'ARRAY(0x21892880)') called at /usr/lib/perl5/site_perl/5.14/i686-cygwin-threads-64int/Moose/Util.pm line 163 Moose::Util::_apply_all_roles('Moose::Meta::Class::__ANON__::SERIAL::1=HASH(0x2189b440)', undef, 'Net::Twitter::Role::API::RESTv1_1', 'Net::Twitter::Role::API::Lists', 'Net::Twitter::Role::OAuth') called at /usr/lib/perl5/site_perl/5.14/i686-cygwin-threads-64int/Moose/Util.pm line 99 Moose::Util::apply_all_roles('Moose::Meta::Class::__ANON__::SERIAL::1=HASH(0x2189b440)', 'Net::Twitter::Role::API::RESTv1_1', 'Net::Twitter::Role::API::Lists', 'Net::Twitter::Role::OAuth') called at /usr/lib/perl5/site_perl/5.14/i686-cygwin-threads-64int/Moose/Meta/Class.pm line 104 Moose::Meta::Class::create('Moose::Meta::Class::__ANON__::SERIAL::1=HASH(0x20caafa0)', 'Moose::Meta::Class::__ANON__::SERIAL::4', 'roles', 'ARRAY(0x21545780)', 'weaken', 1, 'superclasses', 'ARRAY(0x20083418)', 'methods', ...) called at /usr/lib/perl5/site_perl/5.14/i686-cygwin-threads-64int/Class/MOP/Package.pm line 120 Class::MOP::Package::create_anon('Moose::Meta::Class::__ANON__::SERIAL::1=HASH(0x20caafa0)', 'superclasses', 'ARRAY(0x20083418)', 'roles', 'ARRAY(0x21545780)', 'methods', 'HASH(0x215bea40)', 'cache', 0, ...) called at /usr/lib/perl5/site_perl/5.14/i686-cygwin-threads-64int/Class/MOP/Class.pm line 474 Class::MOP::Class::create_anon_class('Moose::Meta::Class::__ANON__::SERIAL::1=HASH(0x20caafa0)', 'superclasses', 'ARRAY(0x20083418)', 'roles', 'ARRAY(0x21545780)', 'methods', 'HASH(0x215bea40)', 'cache', 0, ...) called at /usr/lib/perl5/site_perl/5.14/Net/Twitter.pm line 69 Net::Twitter::_create_anon_class('ARRAY(0x20083418)', 'ARRAY(0x21545780)', 1, 'Net::Twitter_v4_00005_with__API_Lists__API_RESTv1_1__OAuth') called at /usr/lib/perl5/site_perl/5.14/Net/Twitter.pm line 132 Net::Twitter::new(***) called at akb_th_men.pl line 326
意味わからんが、要はAPI::RESTv1_1とAPI::Uploadを一緒に使ってはいかんという事らしい。ちなみに該当部分のコードはここ。
my $nt = Net::Twitter->new( traits => [qw/API::RESTv1_1 API::Lists OAuth/], consumer_key => $consumer_key, consumer_secret => $consumer_secret, );
なんでや!API::Upload使ってないのに!とりあえずAPI::Listsを消すと動くのだが、API::Listsのコードを見てもAPI::Uploadに依存してそうな感じはしないし、よく分からんなー。
気が向いたら明日調べる。