Download the PHP package easybib/api-client-php without Composer
On this page you can find all versions of the php package easybib/api-client-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download easybib/api-client-php
More information about easybib/api-client-php
Files in easybib/api-client-php
Package api-client-php
Short Description Client for EasyBib API, implemented in PHP
License Apache-2.0
Informations about the package api-client-php
PHP Client for EasyBib API
Use this to request data from the EasyBib API. The client uses Guzzle under the hood for the actual HTTP calls.
Installation
This library requires PHP 5.5 or later.
Use Composer to add this project to your project's dependencies.
Your Composer JSON
Once your JSON is set, this will install the package
Usage
Instantiation
Two OAuth grant types are currently supported: JSON Web Token, and Authorization Code.
JSON Web Token Grant
Authorization Code Grant
In order to use an Authorization Code Grant, you will need an
implementation of RedirectorInterface
from the OAuth2 Client library in order
to allow the API client to redirect the user and get back an authorization code.
You can find more information at an example in
the README for that project.
Retrieving api resources
Once you have an API object, you can use it to traverse the API.
The two entry points are $api->getUser()
and $api->getProjects()
.
getUser()
will return a ApiResource
representing the user; calling
getResourceData()->getRelations()
on the user api resource will return a set
of available references which can be called from the user. So the call chain
for a particular project's citations might be
which would return a Collection
of citations. Some more examples:
Session backend
By default, the ApiBuilder
uses native PHP sessions wrapped by a Symfony
session interface. You can implement a different session backend; see
the Symfony docs
for more information.
Resetting the session
It is possible to reset the token store of the OAuth2 client, such as when
a guest user registers or logs in, and needs a new token which will be
associated with the permanent user account. In this case, the application
consuming the API must instantiate a new ApiTraverser
or call setCache()
,
with a new cache or cache namespace, to ensure that the ApiTraverser
will
not return api resources cached during the original session.
By default, ApiTraverser
uses a PHP-array-based cache, so unless you have
implemented a different caching backend, you can simply instantiate a new
ApiTraverser
, either directly or via the ApiBuilder
.
All versions of api-client-php with dependencies
doctrine/cache Version ~1.3
guzzlehttp/guzzle Version ^6.0
easybiblabs/oauth2-client-php Version ^4.1