firelike/nytimes-api

Zend Framework module to consume NY Times APIs

v1.1.3 2016-12-21 00:52 UTC

This package is not auto-updated.

Last update: 2024-11-09 20:45:21 UTC


README

Build Status License

Introduction

Zend Framework module to consume NY Times API

Installation

Install the module using Composer into your application's vendor directory. Add the following line to your composer.json.

{
    "require": {
        "firelike/nytimes-api": "^1.1"
    }
}

Configuration

Enable the module in your application.config.php file.

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

Copy and paste the nytimes.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 nytimes.local.php might look something like the following:

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

Usage

Calling from your code:

        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);
        

Using the console:

php public/index.php nytimes lists -v

Implemented Service Methods:

  • bestSellerList
  • bestSellerHistoryList
  • bestSellerListNames
  • bestSellerListOverview
  • bestSellerListByDate
  • reviews

Links