Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package Net::Twitter::Role::API::UploadImage; | ||
|
||
use Moose::Role; | ||
use Net::Twitter::API; | ||
use DateTime::Format::Strptime; | ||
use URI; | ||
|
||
has upload_url => isa => 'Str', is => 'ro', default => 'http://upload.twitter.com/1.1'; | ||
|
||
after BUILD => sub { | ||
my $self = shift; | ||
|
||
$self->{upload_url} =~ s/^http:/https:/ if $self->ssl; | ||
}; | ||
|
||
base_url 'upload_url'; | ||
authenticate 1; | ||
|
||
our $DATETIME_PARSER = DateTime::Format::Strptime->new(pattern => '%a %b %d %T %z %Y'); | ||
datetime_parser $DATETIME_PARSER; | ||
|
||
|
||
twitter_api_method upload => ( | ||
path => 'media/upload', | ||
method => 'POST', | ||
params => [qw/media/], | ||
required => [qw/media/], | ||
booleans => [qw/possibly_sensitive display_coordinates/], | ||
returns => 'Image', | ||
description => 'Upload images to twitter without posting them on the timeline' | ||
); | ||
|
||
1; | ||
|
||
__END__ | ||
=head1 NAME | ||
Net::Twitter::Role::API::Upload - A definition of the Twitter Upload API as a Moose role | ||
=head1 SYNOPSIS | ||
package My::Twitter; | ||
use Moose; | ||
with 'Net::Twitter::API::Upload'; | ||
=head1 DESCRIPTION | ||
This module provides definitions the Twitter Upload API methods. | ||
=head1 AUTHOR | ||
Allen Haim <allen@netherrealm.net> | ||
Marc Mims <marc@questright.com> | ||
=head1 LICENSE | ||
Copyright (c) 2011 Marc Mims | ||
The Twitter API itself, and the description text used in this module is: | ||
Copyright (c) 2011 Twitter | ||
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |