Thanks for pointing this out. The following code GETs the URL instead of reading contents from file. It can replace the file-reading section of my previous post:
#use Encode; # used previously
use LWP::UserAgent;
my $ua = LWP::UserAgent->new();
my $URL = 'https://public-api.wordpress.com/rest/v1/read/feed/http%3A%
+2F%2Fthe-art-of-autism.com%2Ffeed';
my $response = $ua->get($URL);
die $response->status_line unless $response->is_success;
my $contents = Encode::encode 'UTF-8', $response->decoded_content;
...
All in all, Mojo::UserAgent solution by marto is more high-level. But I love plain LWP::UserAgent. Note: above can be made to authenticate and save cookies. |