firelike / nytimes-api

Zend Framework module to consume NY Times APIs


NY Times API Client

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

No license file found for this Module
php composer.phar require "firelike/nytimes-api"

Require

  • php: ^5.6 || ^7.0
  • zendframework/zend-servicemanager: ^3.1
  • zendframework/zend-mvc-console: ^1.1
  • guzzlehttp/guzzle-services: ^1.0

Require Dev

  • phpunit/phpunit: ^5.7