There is no element named "meta.links.self" in the returned JSON, so when you try to set $feedurl to that it is unititialised.
Also, you call $ua->get($url)->result->json twice in the space of 3 lines. DRY.
use strict; use warnings; use Mojo::UserAgent; use Data::Dumper; my $url = 'https://public-api.wordpress.com/rest/v1/read/feed/34259929 +'; my $ua = Mojo::UserAgent->new; my $json = $ua->get($url)->res->json; print Dumper ($json); my $subscribers = $json->{subscribers_count}; print "\nNumber of subscribers: $subscribers\n"; my $feedurl = $json->{meta}{links}{self}; print "URL is $feedurl\n";
This works for me. My version of Mojo::UserAgent (Mojolicious 5.77) does not have a result method. YMMV.
In reply to Re^4: Running JavaScript from within Perl (or just use the API)
by hippo
in thread Running JavaScript from within Perl
by anautismobserver
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |