in reply to Re^3: Running JavaScript from within Perl (or just use the API)
in thread Running JavaScript from within Perl

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.

Replies are listed 'Best First'.
Re^5: Running JavaScript from within Perl (or just use the API)
by anautismobserver (Sexton) on Sep 23, 2019 at 19:11 UTC

    I responded in error (figured out my mistake). How do I delete my response?

      How do I delete my response?

      You shouldn't, perhaps only <strike> out the things no longer relevant and mark edits with "Update". See How do I change/delete my post?

        Nobody lost a learning opportunity through missing the post I deleted, which posed a question that was already answered elsewhere in the thread.

        Is it possible for me to get am email notice every time someone contributes to a thread I originated? I didn't see an option for that in the Settings.

        Thanks to everyone who responded to this thread. You folks have been extremely helpful to me and I worry about trying your patience. I now have a script that appears to work and do what I wanted (though I'm still testing it).