Skip to content

Commit

Permalink
upload images endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ghathwar committed Jul 14, 2014
1 parent 9da488e commit 14206cf
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/Net/Twitter/Role/API/RESTv1_1.pm
Expand Up @@ -6,6 +6,8 @@ use Net::Twitter::API;
use DateTime::Format::Strptime;
use URI;

with 'Net::Twitter::Role::API::UploadImage';

# API v1.1 incorporates the Search and Upload APIs
excludes map "Net::Twitter::Role::$_", qw/API::Search API::Upload Net::Twitter::Role::RateLimit/;

Expand Down
65 changes: 65 additions & 0 deletions lib/Net/Twitter/Role/API/UploadImage.pm
@@ -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.

0 comments on commit 14206cf

Please sign in to comment.