NAME

Mojo::WebService::Twitter::Media - Media associated with a tweet

SYNOPSIS

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";
}

DESCRIPTION

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.

ATTRIBUTES

source

my $href = $media->source;

Source data hashref from Twitter API.

display_url

my $url = $media->display_url;

URL of the media for display purposes.

expanded_url

my $url = $media->expanded_url;

Expanded version of "display_url".

id

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.

media_url

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".

source_status_id

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.

type

my $type = $media->type;

Media type, one of photo, video, or animated_gif.

tweet

my $tweet = $media->tweet;

Tweet in which the media is contained, as a Mojo::WebService::Twitter::Tweet object.

variants

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.

METHODS

Mojo::WebService::Twitter::Media inherits all methods from Mojo::Base, and implements the following new ones.

from_source

$media = $media->from_source($hr);

Populate attributes from hashref of Twitter API source data.

BUGS

Report any issues on the public bugtracker.

AUTHOR

Dan Book <dbook@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2015 by Dan Book.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)

SEE ALSO

Mojo::WebService::Twitter