AnyEvent-Twitter

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

Revision history for Perl extension AnyEvent::Twitter

0.64    Fri Jan 11 22:16:43 2013
        - add deps (Time::Piece) 
          Time::Piece was first released with perl v5.9.5

0.63    Sun Jan  6 21:30:43 2013
        - add parse_timestamp method
        - support REST API Version 1.1
        - support media uploading

0.62    Thu Jul 21 20:00:39 JST 2011
        - documentation fix
        - clean code up

0.61    Wed Jul 20 06:12:29 JST 2011
        - remove deps: Net::Twitter::Lite
        - document get_access_token() and get_request_token()

0.60    Wed Jul 20 04:30:23 JST 2011

lib/AnyEvent/Twitter.pm  view on Meta::CPAN

=item C<< $ua->post($url, \%params, sub {}) >>

=item C<< $ua->post($api, \@params, sub {}) >>

=item C<< $ua->post($url, \@params, sub {}) >>

=back

=head3 UPLOADING MEDIA FILE

You can use C<statuses/update_with_media> API to upload photos by specifying parameters as arrayref like below example.

Uploading photos will be tranferred with Content-Type C<multipart/form-data> (not C<application/x-www-form-urlencoded>)

    use utf8;
    $ua->post(
        'statuses/update_with_media',
        [
            status    => '桜',
            'media[]' => [ undef, $filename, Content => $loaded_image_binary ],
        ],

xt/update_with_media.t  view on Meta::CPAN


subtest 'single file' => sub {
    my $ua = AnyEvent::Twitter->new(%$config);

    my $cv = AE::cv;

    $cv->begin;
    $ua->get('help/configuration', sub {
        my ($hdr, $res, $reason) = @_;
        note explain $res;
        is $res->{max_media_per_upload}, 1, 'keep watch on a allowed media counts';
        $cv->end;
    });

    {
        no utf8;
        $cv->begin;
        $ua->post('statuses/update_with_media',
            [
                status => 'いろはにほへと ' . rand,
                'media[]' => [ undef, 'filename', Content => $image_1 ],

xt/update_with_media.t  view on Meta::CPAN

        my ($hdr, $res, $reason) = @_;
        is($res->{user}{screen_name}, $screen_name, "account/verify_credentials");
        note explain \@_;
        $cv->end;
    });

    $cv->recv;
};

subtest 'multiple files' => sub {
    plan skip_all => 'not allowed us to upload multiple files yet';
};

done_testing;



( run in 0.700 second using v1.01-cache-2.11-cpan-b16cb0d3907 )