PHP code example of firelike / nytimes-api

1. Go to this page and download the library: Download firelike/nytimes-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

firelike / nytimes-api example snippets


return array(
    'modules' => array(
        'Firelike\NYTimes'
    )
);


return [
    'nytimes_service' => [
        'api_key' => '<your-api-key>',
    ]
];

        use Firelike\NYTimes\Request\AbstractRequest;
        use Firelike\NYTimes\Request\Books\Lists;
        use Firelike\NYTimes\Service\BooksService;

        $service = new BestSellersService();
        
        $request = new Lists();
        $request->setList('hardcover-fiction')
            ->setSortOrder(AbstractRequest::SORT_ORDER_ASC);

        $result = $this->getService()->bestSellerList($request);
        
        $numberOfRecords = $result->toArray()['num_results];
        var_dump($numberOfRecords);

        $records= $result->toArray()['results];
        var_dump($records);
        

php public/index.php nytimes lists -v