Mojo::WebService::Twitter::Media - Media associated with a tweet
use Mojo::WebService::Twitter; my $twitter = Mojo::WebService::Twitter->new(api_key => $api_key, api_secret => $api_secret); my $tweet = $twitter->get_tweet($tweet_id); my $media = $tweet->media; foreach my $item (@$media) { my $media_type = $item->type; my $media_url = $item->media_url; say "Media ($media_type): $media_url"; }
Mojo::WebService::Twitter::Media is an object representing native media associated with a Twitter tweet. See https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/extended-entities-object for more information.
my $href = $media->source;
Source data hashref from Twitter API.
my $url = $media->display_url;
URL of the media for display purposes.
my $url = $media->expanded_url;
Expanded version of "display_url".
my $media_id = $media->id;
Media identifier. Note that media IDs are usually too large to be represented as a number, so should always be treated as a string.
my $url = $media->media_url;
Direct URL to media of "type" photo, or a static thumbnail for media of type video or animated_gif. Direct access to these types of media may be found in "variants".
photo
video
animated_gif
my $tweet_id = $media->source_status_id;
Tweet ID which media was originally associated with, or undef if media was originally associated with the current tweet.
undef
my $type = $media->type;
Media type, one of photo, video, or animated_gif.
my $tweet = $media->tweet;
Tweet in which the media is contained, as a Mojo::WebService::Twitter::Tweet object.
my $variants = $media->variants;
Array reference of variant hashrefs for media of "type" video or animated_gif, with keys content_type, url, and possibly bitrate, representing direct access to the media if available.
content_type
url
bitrate
Mojo::WebService::Twitter::Media inherits all methods from Mojo::Base, and implements the following new ones.
$media = $media->from_source($hr);
Populate attributes from hashref of Twitter API source data.
Report any issues on the public bugtracker.
Dan Book <dbook@cpan.org>
This software is Copyright (c) 2015 by Dan Book.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
Mojo::WebService::Twitter
To install Mojo::WebService::Twitter, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojo::WebService::Twitter
CPAN shell
perl -MCPAN -e shell install Mojo::WebService::Twitter
For more information on module installation, please visit the detailed CPAN module installation guide.