2017 © Pedro Peláez
 

library qbank3api-phpwrapper

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

image

nodeone/qbank3api-phpwrapper

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  • Wednesday, October 25, 2017
  • by mikke.schiren@digitalistgroup.com
  • Repository
  • 15 Watchers
  • 0 Stars
  • 84 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 74 Versions
  • 8 % Grown

The README.md

QBank 3 API PHP Wrapper

Latest Stable Version Latest Unstable Version License, (*1)

Introduction

QBank 3 API PHP Wrapper is a library that makes it easy to use the QBank 3 API directly from PHP. No need to handle the connections or interpreting the results yourself., (*2)

Installation

Install via composer., (*3)

{
    "require": {
        "qbnk/qbank3api-phpwrapper": "dev-master"
    }
}

Usage

This documentation presumes that you have a firm grasp of the concepts in QBank. If you do not or perhaps want a reference to lean on, please read the articles in the Knowledge Base for QBank. The Knowledge Base is found at: support.qbank.se, (*4)

Instantiate the wrapper by creating a new QBankApi. The QBankApi class constructor takes three arguments of which two are required. The first is the URL to the api of the QBank you want to connect to. If the QBank is hosted by QBNK the domain of the QBank is sufficient; otherwise the full URL to the API endpoint is needed., (*5)

The second argument is a Credentials object which contains all necessary information to authenticate against QBank. These are as follows:, (*6)

  • Client id - A unique id used to identify the caller. Issued by QBNK and usually per organisation.
  • Username - A username of a user in the QBank that you are connecting to. The access to content and actions are determined by this.
  • Password - The users password.

To get a client id issued, please contact us at support@qbank.se, (*7)

<?php

use QBNK\QBank\API\QBankApi;
use QBNK\QBank\API\Credentials;

$credentials = new Credentials('CLIENT_ID', 'myUsername', 'myPassword');
$qbankApi = new QBankApi('customer.qbank.se', $credentials);

Searching

Searching is essential to find Media in QBank. Usually one would have at least some criteria for listing Media but even when wanting to display everything searching is the way to go. To find every Media in QBank you would execute a search with no parameters. With no filtering options set, the search would match everything just like the * wildcard in the terminal or similar., (*8)

<?php

use QBNK\QBank\API\QBankApi;
use QBNK\QBank\API\Credentials;
use QBNK\QBank\API\Model\Search;

$credentials = new Credentials('CLIENT_ID', 'myUsername', 'myPassword');
$qbankApi = new QBankApi('customer.qbank.se', $credentials);
$results = $qbankApi->search()->search(new Search());
var_dump(count($results));  // Prints: int(50)

But why did we only get 50 results when our QBank contains thousands of Media? The simple answer is that searches are paginated to not flood you with data and return to you in a reasonable amount of time. The default page size is 50. It is pretty simple to get several pages of results with the number of results of your choosing in each., (*9)

<?php

use QBNK\QBank\API\QBankApi;
use QBNK\QBank\API\Credentials;
use QBNK\QBank\API\Model\Search;

$credentials = new Credentials('CLIENT_ID', 'myUsername', 'myPassword');
$qbankApi = new QBankApi('customer.qbank.se', $credentials);
$search = new Search();
$search->setLimit(10);
for ($i = 0; $i < 5; $i++) {
    $search->setOffset($i * $search->getLimit());
    $results = $qbankApi->search()->search($search);
    var_dump(count($results));
}

/* 
Prints: 
int(10)
int(10)
int(10)
int(10)
int(10)
*/

The results of an executed Search is a SearchResult object. This is merely a wrapper class around an array of Media objects, but with some extra information tacked on. One of these are the very useful getTotalHits() method. With it you can search with a reasonable limit and still print out the number of total results. You can then write code to fetch more results when needed., (*10)

SearchResult also implements Iterator so that you can loop over it just as a regular array. This makes it easy to display your results., (*11)

<?php

use QBNK\QBank\API\QBankApi;
use QBNK\QBank\API\Credentials;
use QBNK\QBank\API\Model\Search;

$credentials = new Credentials('CLIENT_ID', 'myUsername', 'myPassword');
$qbankApi = new QBankApi('customer.qbank.se', $credentials);
$results = $qbankApi->search()->search(new Search());
var_dump(count($results));  // Prints: int(50)
var_dump($results->getTotalHits()); // Prints: int(34814);
foreach ($results as $media) {  //Prints a list of 50 media id and name combinations 
    echo 'ID: '.$media->getMediaId().' Name: '.$media->getName()."\n";
}

Searching with criteria

Usually we have some default criteria such as Media belonging to specific Category or maybe deployed to a specific site. This is easily done by adding criteria to the Search object., (*12)

<?php

use QBNK\QBank\API\QBankApi;
use QBNK\QBank\API\Credentials;
use QBNK\QBank\API\Model\Search;

$credentials = new Credentials('CLIENT_ID', 'myUsername', 'myPassword');
$qbankApi = new QBankApi('customer.qbank.se', $credentials);
$search = new Search()
    ->setCategoryIds([1, 2]);
    ->setDeploymentSiteIds([1])
;
$results = $qbankApi->search()->search($search);

You may also want to filter on a Property. This is done by adding a PropertyCriteria to your search object. This will however not get those set in the SearchResult. To get Property values for Media in a SearchResult a PropertyRequest has to be added to the Searchobject., (*13)

<?php

use QBNK\QBank\API\QBankApi;
use QBNK\QBank\API\Credentials;
use QBNK\QBank\API\Model\Search;

$credentials = new Credentials('CLIENT_ID', 'myUsername', 'myPassword');
$qbankApi = new QBankApi('customer.qbank.se', $credentials);
$search = new Search()
    ->setProperties([
        new PropertyRequest()->setSystemName('property1'),
        new PropertyCriteria()->setSystemName('property2')
    ])
;
$results = $qbankApi->search()->search($search);

There are many more possibilities to filter your searching by and this has just been a demonstration of some of the most used ones. Browse through the setters in the Search class and it should be pretty obvious what is possible., (*14)

Events

Events are calls that are made to report back to QBank that something has happened worthy of statistics collection, an event. Statistics for events are shown in QBank., (*15)

To be able to report an event a session id must be obtained. The session id identifies the acting user over a period of time. To obtain a session id, a session source must be provided. The session source identifies the source of the event (eg. frontend, api, app). To get a session source issued, contact support@qbank.se., (*16)

<?php

use QBNK\QBank\API\QBankApi;
use QBNK\QBank\API\Credentials;
use QBNK\QBank\API\Model\Search;

$credentials = new Credentials('CLIENT_ID', 'myUsername', 'myPassword');
$qbankApi = new QBankApi('customer.qbank.se', $credentials);
$sessionId = $qbankApi->events()->session(SESSION_SOURCE_ID, 'identifierhash', '127.0.0.1', 'CustomApp/1.0', USER_ID);
$qbankApi->events()->view($sessionId, MEDIA_ID);

To report custom events (the ones not covered by the methods available), just use the custom() method. These will be displayed in the statistics alongside the other., (*17)

<?php

use QBNK\QBank\API\QBankApi;
use QBNK\QBank\API\Credentials;
use QBNK\QBank\API\Model\Search;

$credentials = new Credentials('CLIENT_ID', 'myUsername', 'myPassword');
$qbankApi = new QBankApi('customer.qbank.se', $credentials);
$sessionId = $qbankApi->events()->session(SESSION_SOURCE_ID, 'identifierhash', '127.0.0.1', 'CustomApp/1.0', USER_ID);
$qbankApi->events()->custom($sessionId, MEDIA_ID, 'Some custom event');

It is also possible to report external usage eg. from a CMS or other. This is not shown in the statistics, but in the media detail in QBank. This provides a good overview of where a media is used. Of course you can also remove the usage report if it is no longer in use. See the methods addUsage() and removeUsage() respectively., (*18)

The Versions

25/10 2017

dev-master

9999999-dev

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

28/03 2017

1.3.x-dev

1.3.9999999.9999999-dev

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

28/03 2017

v1.3.0

1.3.0.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

16/03 2017

v1.2.14

1.2.14.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

14/03 2017

v1.2.13

1.2.13.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

24/02 2017

v1.2.12

1.2.12.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

08/02 2017

v1.2.11

1.2.11.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

18/12 2016

v1.2.10

1.2.10.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

06/12 2016

v1.2.9

1.2.9.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

07/11 2016

v1.2.8

1.2.8.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

18/10 2016

v1.2.7

1.2.7.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

21/09 2016

v1.2.6

1.2.6.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

19/09 2016

v1.2.5

1.2.5.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

09/06 2016

v1.2.4

1.2.4.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

09/06 2016

v1.2.3

1.2.3.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

08/06 2016

v1.2.2

1.2.2.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

08/06 2016

v1.2.1

1.2.1.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

24/05 2016

1.2.0

1.2.0.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

02/03 2016

v1.1.0

1.1.0.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

22/02 2016

v1.0.14

1.0.14.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

18/02 2016

1.1.x-dev

1.1.9999999.9999999-dev

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

15/01 2016

v1.0.13

1.0.13.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

14/01 2016

v1.0.12

1.0.12.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

01/12 2015

v1.0.11

1.0.11.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

01/12 2015

v1.0.10

1.0.10.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

19/11 2015

1.0.9

1.0.9.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

05/11 2015

v1.0.8

1.0.8.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

02/11 2015

v1.0.7

1.0.7.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

12/10 2015

v1.0.6

1.0.6.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

02/10 2015

v1.0.5

1.0.5.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

01/10 2015

v1.0.4

1.0.4.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

09/09 2015

v1.0.3

1.0.3.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

28/08 2015

v1.0.2

1.0.2.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

27/08 2015

v1.0.1

1.0.1.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

27/08 2015

v1.0.0

1.0.0.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

27/08 2015

1.0.x-dev

1.0.9999999.9999999-dev

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

13/03 2015

v0.14.1

0.14.1.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

02/03 2015

v0.14.0

0.14.0.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

02/02 2015

v0.13.0

0.13.0.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

11/12 2014

v0.12.1

0.12.1.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

08/12 2014

v0.12.0

0.12.0.0

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

05/11 2014

v0.11.3-alpha

0.11.3.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

05/11 2014

v0.11.2-alpha

0.11.2.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

04/11 2014

v0.11.1-alpha

0.11.1.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

31/10 2014

v0.11.0-alpha

0.11.0.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

23/10 2014

v0.10.5-alpha

0.10.5.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

23/10 2014

v0.10.4-alpha

0.10.4.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

22/10 2014

v0.10.3-alpha

0.10.3.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

22/10 2014

v0.10.2-alpha

0.10.2.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

22/10 2014

v0.10.1-alpha

0.10.1.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

15/10 2014

v0.10.0-alpha

0.10.0.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

15/10 2014

v0.9.0-alpha

0.9.0.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

13/10 2014

v0.8.0-alpha

0.8.0.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

10/10 2014

v0.7.0-alpha

0.7.0.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

10/10 2014

v0.6.4-alpha

0.6.4.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

09/10 2014

v0.6.3-alpha

0.6.3.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

03/10 2014

v0.6.2-alpha

0.6.2.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

02/10 2014

v0.6.1-alpha

0.6.1.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

30/09 2014

v0.6.0-alpha

0.6.0.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

30/09 2014

v0.5.1-alpha

0.5.1.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

30/09 2014

v0.5.0-alpha

0.5.0.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

29/09 2014

v0.4.2-alpha

0.4.2.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

26/09 2014

v0.4.1-alpha

0.4.1.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

25/09 2014

v0.4.0-alpha

0.4.0.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

24/09 2014

v0.3.0-alpha

0.3.0.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

23/09 2014

v0.2.0-alpha

0.2.0.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

18/09 2014

v0.1.8-alpha

0.1.8.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

18/09 2014

v0.1.7-alpha

0.1.7.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

16/09 2014

v0.1.6-alpha

0.1.6.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

16/09 2014

v0.1.5-alpha

0.1.5.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

15/09 2014

v0.1.4-alpha

0.1.4.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

12/09 2014

v0.1.3-alpha

0.1.3.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

12/09 2014

v0.1.2-alpha

0.1.2.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank

12/09 2014

v0.1.1-alpha

0.1.1.0-alpha

A PHP-Wrapper for QBank 3's API. Provides a simple way to communicate with QBank 3 from PHP.

  Sources   Download

MIT

The Requires

 

api qbank