Catmandu-Importer-OpenAIRE
view release on metacpan or search on metacpan
lib/Catmandu/Importer/OpenAIRE.pm view on Meta::CPAN
return undef unless defined($records);
}
return shift(@$records);
};
}
sub fetchRecords {
my ($self,$page) = @_;
my @params = (
"format=json",
"page=$page"
);
for my $param (@BASE_PARAM) {
if (defined $self->{$param}) {
push @params , "$param=" . uri_escape($self->{$param});
}
}
my $url = sprintf "%s?%s", $self->url , join("&",@params);
my $result;
eval {
my $json = get($url);
my $data = decode_json($json);
if ($data &&
$data->{response} &&
$data->{response}->{results} &&
$data->{response}->{results}->{result}) {
$result = $data->{response}->{results}->{result};
}
else {
$result = undef;
}
};
if ($@) {
warn "Oh no! [$@] for $url";
}
return $result;
}
1;
__END__
=head1 NAME
Catmandu::Importer::OpenAIRE - Package that queries the OpenAIRE Graph
=head1 SYNPOSIS
# From the command line
# Harvest some data
catmandu convert OpenAIRE to YAML
# Harvest some data from a different endpoint
catmandu convert OpenAIRE --url http://api.openaire.eu/search/datasets to YAML
=head1 DESCRIPTION
See L<https://graph.openaire.eu/develop/api.html> for the OpenAIRE query parameters
=head1 AUTHOR
Patrick Hochstenbach, C<< <patrick.hochstenbach at ugent.be> >>
=head1 LICENSE
Copyright 2023- Ghent University Library
This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
=cut
( run in 2.494 seconds using v1.01-cache-2.11-cpan-97f6503c9c8 )