Web::NewsAPI::Source - Object class representing a News API source
use v5.10; use Web::NewsAPI; my $newsapi = Web::NewsAPI->new( api_key => $my_secret_api_key, ); say "Here are some sources for English-language science news..."; my @sources = $newsapi->sources( category => 'science', language => 'en' ); for my $source ( @sources ) { say $source->name; if ( defined $source->id ) { say "...it has the NewsAPI ID " . $source->id; } else { say "...but it doesn't have a NewsAPI ID."; } }
Objects of this class represent a News API news source. Generally, you won't create these objects yourself; you'll get them as a result of calling sources() on a Web::NewsAPI object.
These are all read-only attributes, based on information provided by News API. They are all strings, except for url, which is a URI object. Any of them might be undefined, except for name.
url
name
my $id = $source->id;
my $name = $source->name;
my $desc = $source->description;
my $url = $source->url;
my $category = $source->category;
my $language_code = $source->language;
my $country_code = $source_country;
Jason McIntosh (jmac@jmac.org)
To install Web::NewsAPI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Web::NewsAPI
CPAN shell
perl -MCPAN -e shell install Web::NewsAPI
For more information on module installation, please visit the detailed CPAN module installation guide.