2017 © Pedro Peláez
 

library api

Wrapper for Bookboon API

image

bookboon/api

Wrapper for Bookboon API

  • Wednesday, December 6, 2017
  • by bookboon
  • Repository
  • 4 Watchers
  • 3 Stars
  • 14,120 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 52 Versions
  • 13 % Grown

The README.md

Bookboon API PHP Class

Build Status Code Climate Test Coverage, (*1)

The PHP class is a wrapper for the Bookboon.com API. Because this is just a wrapper class you should familiarize yourself with the REST api before using it., (*2)

Usage

To use the Bookboon AIP you are required to have an application id and secret ($API_ID and $API_SECRET below), see the API page for details. Install via composer:, (*3)

composer require bookboon/api

To use it without composer, use with any PSR-0 compatible autoloader or require every file manually., (*4)

The simplest way to get a book is to use the getBook method:, (*5)

$bookboon = new Bookboon($API_ID, $API_SECRET, array(/*optional named array to set request headers*/));
$book = $bookboon->getBook("BOOK_GUID");

That will return a Book object with public getters for every property. There are plenty more simple get functions:, (*6)

$category = $bookboon->getCategory("CATEGORY_GUID"); // return Category object
$reviews = $bookboon->getReviews("BOOK_GUID"); // return array of Review
$search = $bookboon->getSearch("query text"); // return array of Book
$recommendations = $bookboon->getRecommendations(array("BOOK_ID_1", "BOOK_ID_2"); // return array of Book
$questions = $bookboon->getQuestions(); // return array of Question

Finally you can download a book usually the following, you need to send a unique user identifier handle for every unique user (for instance a user id, email):, (*7)

$url = $bookboon->getBookDownloadUrl("BOOK_GUID", array("handle" => "user@email"));
// Send the $url in a redirect header to the user

Important: Do NOT store this value as it will change constantly., (*8)

Use api raw

You can also use the api method to get database from the API. To pass variables to the API send an array with the api function:, (*9)

/* The bacon-loving student */
$vars = array('post' => array( 'answer[0]' => '6230e12c-68d8-45d5-8f02-1d3997713150',
                               'answer[1]' => '5aca0fe1-0d93-41b1-8691-aa242a526f17'
                             )
             );

$bookboon->api('/questions', $vars);

Note: To make the php class more versatile you need to tell it whether to pass variables using POST or GET methods. The api function will only accept keys named 'post' and 'get' and parse their respective arrays into the correct query strings., (*10)

Result

Results from the api method is json decoded arrays of data directly from the API, if you use any of the other methods (getbooks, getCategories etc.) an appropiate object will be returned., (*11)

Exceptions

The wrapper will throw a few different exceptions. If API responds with an unhandled HTTP status such as if a variabls are missing (403), the posted data is malformed (400) or an unknown API error (500). You may wish to catch these errors, like so:, (*12)

$bookboon = new Bookboon($API_ID, $API_SECRET);

try {
    print_r($bookboon->api('/recommendations', array(
        'get' => array(
            'books' => $book_id
        )));
} 
catch (NotFoundException $e) {
    // handle exception here
}

Right now we throw the following exceptions:, (*13)

ApiSyntaxException - Usually missing or malformed parameters
AuthenticationException - Bad credentials
GeneralApiException - When some unknown goes wrong, please report this to us
NotFoundException - API returns not found status (404), (*14)

Cache

The wrapper class provides a cache interface to be used to speed up GET queries. At the moment only memcached is implemented. To set the cache provider use the setCache method:, (*15)

$bookboon->setCache(new \Bookboon\Api\Memcached($server, $port, $timeToLive));

To implement your own provider cache software, make sure your interface imlements \Bookboon\Api\Cache. It only has three methods: save, get and delete, so it should be easy enough to do., (*16)

The Versions

06/12 2017

dev-master

9999999-dev https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

06/12 2017

v3.4

3.4.0.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

06/12 2017

dev-hotfix/incorrectPara

dev-hotfix/incorrectPara https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

28/09 2017

v3.3

3.3.0.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

28/09 2017

dev-hotfix/brokenMethod

dev-hotfix/brokenMethod https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

29/08 2017

v3.2

3.2.0.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

29/08 2017

dev-hotfix/incorrectCache

dev-hotfix/incorrectCache https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

19/05 2017

v3.1

3.1.0.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

19/05 2017

dev-hotfix/fixes

dev-hotfix/fixes https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

18/05 2017

v3.0

3.0.0.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

18/05 2017

dev-feature/responseObj

dev-feature/responseObj https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

20/04 2017

v2.3.4

2.3.4.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

27/02 2017

v2.3.3

2.3.3.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

27/02 2017

dev-feature/bookTypeRecommendations

dev-feature/bookTypeRecommendations https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

16/02 2017

v2.3.2

2.3.2.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

16/02 2017

v2.3.1

2.3.1.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

16/02 2017

dev-feature/customAuthParams

dev-feature/customAuthParams https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

15/02 2017

v2.3

2.3.0.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

15/02 2017

v2.2.1

2.2.1.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

31/01 2017

v2.2

2.2.0.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

31/01 2017

dev-feature/examByBookId

dev-feature/examByBookId https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

27/01 2017

v2.1.1

2.1.1.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

28/11 2016

v2.1

2.1.0.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

24/11 2016

v2.0.5

2.0.5.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

24/11 2016

v2.0.4

2.0.4.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

24/11 2016

v2.0.3

2.0.3.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

24/11 2016

v2.0.2

2.0.2.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

23/11 2016

v2.0

2.0.0.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

23/11 2016

v2.0.1

2.0.1.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

22/11 2016

2.x-dev

2.9999999.9999999.9999999-dev https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

 

The Development Requires

api wrapper

03/11 2016

1.x-dev

1.9999999.9999999.9999999-dev https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.3.0

 

The Development Requires

api wrapper

31/10 2016

v1.4.1

1.4.1.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.3.0

 

The Development Requires

api wrapper

24/10 2016

v1.4

1.4.0.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.3.0

 

The Development Requires

api wrapper

13/05 2016

v1.3.4

1.3.4.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.3.0

 

The Development Requires

api wrapper

10/02 2016

v1.3.3

1.3.3.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.3.0

 

The Development Requires

api wrapper

09/02 2016

v1.3.2

1.3.2.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.3.0

 

The Development Requires

api wrapper

09/02 2016

v1.3.1

1.3.1.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.3.0

 

The Development Requires

api wrapper

09/02 2016

v1.3

1.3.0.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.3.0

 

The Development Requires

api wrapper

12/01 2016

v1.2.6

1.2.6.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.3.0

 

The Development Requires

api wrapper

12/01 2016

dev-getData

dev-getData https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.3.0

 

The Development Requires

api wrapper

23/12 2015

v1.2.5

1.2.5.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.3.0

 

The Development Requires

api wrapper

09/12 2015

v1.2.4

1.2.4.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.3.0

 

The Development Requires

api wrapper

08/12 2015

v1.2.3

1.2.3.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.3.0

 

The Development Requires

api wrapper

08/12 2015

v1.2.2

1.2.2.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.3.0

 

The Development Requires

api wrapper

04/12 2015

v1.2.1

1.2.1.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.3.0

 

The Development Requires

api wrapper

04/12 2015

v1.2

1.2.0.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.3.0

 

The Development Requires

api wrapper

04/12 2015

v1.1.5

1.1.5.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.3.0

 

The Development Requires

api wrapper

03/12 2015

v1.1.4

1.1.4.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.3.0

 

api wrapper

03/12 2015

v1.1.3

1.1.3.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.3.0

 

api wrapper

02/12 2015

v1.1.2

1.1.2.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.3.0

 

api wrapper

02/12 2015

v1.1.1

1.1.1.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.3.0

 

api wrapper

01/12 2015

v1.1

1.1.0.0 https://github.com/bookboon/api-php

Wrapper for Bookboon API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • ext-json *
  • php >=5.3.0

 

api wrapper