Created
March 12, 2012 11:10
-
-
Save yupe/2021239 to your computer and use it in GitHub Desktop.
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
use strict; | |
use warnings; | |
use 5.010; | |
use Data::Dumper; | |
use Mojo::UserAgent; | |
use Mojo::JSON; | |
my $user = 'xomaa'; | |
my $url = "https://api.twitter.com/1/favorites.json?count=3&include_entities=1&id=$user"; | |
my $ua = Mojo::UserAgent->new; | |
my $result = $ua->get($url)->res->json; | |
foreach my $tweet (@$result) { | |
say 'Text is => ',$tweet->{text}; | |
say 'Id is => ',$tweet->{id}; | |
#обработка ссылок из твита | |
if(exists $tweet->{entities}->{urls} && ref $tweet->{entities}->{urls} eq 'ARRAY') { | |
#доп проверка - проходит на УРА! | |
if(ref $tweet->{entities}->{urls} eq 'ARRAY') { | |
# печатает "ARRAY" | |
say ref $tweet->{entities}->{urls}; | |
# в этом цикле вылетает с "Not an ARRAY reference at file.pl line 23" | |
foreach my $link (@$tweet->{entities}->{urls}){ | |
say $link->{expanded_url}; | |
} | |
} | |
} | |
say "==========================\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Решено вот так foreach my $link (@{$tweet->{entities}->{urls}}){