Laminas/Zend Framework module with API client to access USA Today BestSellers API
Install the module using Composer into your application's vendor directory. Add the following line to your
composer.json
.
{
"require": {
"firelike/usatoday-api-client": "1.*"
}
}
Enable the module in your application.config.php
file.
return array(
'modules' => array(
'Firelike\USAToday'
)
);
Copy and paste the usatoday.local.php.dist
file to your config/autoload
folder and customize it with your credentials and
other configuration settings. Make sure to remove .dist
from your file.Your usatoday.local.php
might look something like the following:
<?php
return [
'usat_service' => [
'service_url' => 'http://api.usatoday.com/open/bestsellers/books',
'api_key' => '<your-usa-today-api-key>'
]
];
Calling from your code:
use Firelike\USAToday\Service\BestSellersService;
$service = new BestSellersService();
$options = [
'year' => '2016',
'month' => '10',
'date' => '20'
];
$records = $service->booklists($options);
var_dump($records);
Using the console:
php public/index.php usatoday fetch-booklists -v
- booklists
- dates
- categories