Salam,
as Net::Twitter::Lite version 0.10004, there's no function for update_with_media.
as i'm really need to post some pic to twitter. i make some changes to very useful easy to use Net::Twitter::Lite.
changes only ad file Lite.pm.
add after line: 23
uploadurl => 'http://upload.twitter.com/1',
at line: 331, change from
Content_Type => 'form-data',to
Content_Type => 'multipart/form-data',*i'm just playing safe with this.
at line: 387, change from
? POST($uri, Content_Type => 'form-data', Content => [ %$args ])to
? POST($uri, Content_Type => 'multipart/form-data', Content => [ %$args ])*i'm just playing safe with this too.
Add after line: 1198
[ 'update_with_media', {
aliases => [ qw// ],
path => 'statuses/update_with_media',
method => 'POST',
params => [ qw/status media[] lat long place_id display_coordinates in_reply_to_status_id trim_user include_entities/ ],
required => [ qw/status media[]/ ],
add_source => 1,
deprecated => 0,
authenticate => 1,
booleans => [ qw/display_coordinates trim_user include_entities/ ],
base_url_method => 'uploadurl',
} ],
That's all.
And to use this function:
$result = eval { $nt->update_with_media({status => "$tweettext", media => ["/path/to/image.png"]}) };
my previous post, Post to Twitter Using Perl
You can download Lite.pm here.

No comments:
Post a Comment