firelike/litres-api

Zend Framework module to consume LitRes APIs

v1.0.0 2016-12-31 03:04 UTC

This package is not auto-updated.

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


README

Build Status License

Introduction

Zend Framework module to consume LitRes API

Installation

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

{
    "require": {
        "firelike/litres-api": "^1.0"
    }
}

Configuration

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

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

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

<?php
return [
    'litres_service' => [
        'log'=>[
            'enable'=>false,
            'message_formats'=>[
                '{method} {uri} HTTP/{version} {req_body}',
                'RESPONSE: {code} - {res_body}',
            ],
            'logger'=>[
                 'stream' => 'php://output',
            ]
        ]
    ]
];

Usage

Calling from your code:

        use Firelike\LitRes\Request\AbstractRequest;
        use Firelike\LitRes\Request\Browser as BrowserRequest;
        use Firelike\LitRes\Service\LitResService;

        
        $request = new BrowserRequest();
        $request->setSearch('King')
            ->setLang('en')
            ->setLimit(25);

        $service = new LitResService();
        $result = $service->browser($request);
        
        $numberOfRecords = $result->toArray()['results'];
        var_dump($numberOfRecords);

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

Using the console:

php public/index.php litres browser --search=King -v

Implemented Service Methods:

  • browser
  • genres
  • persons

Links