VuFind API Documentation

LibGuides
in package
implements OauthServiceInterface, HttpServiceAwareInterface, LoggerAwareInterface Uses OauthServiceTrait, HttpServiceAwareTrait, LoggerAwareTrait

LibGuides API connection class.

Note: This is for the LibGuides API used by the LibGuidesProfile recommendation service, this is not for the LibGuides search widget "API" used by the LibGuides and LibGuidesAZ data sources.

Closely adapted from VuFind\DigitalContent\OverdriveConnector.

Tags
category

VuFind

author

Demian Katz demian.katz@villanova.edu

author

Brent Palmer brent-palmer@icpl.org

author

Maccabee Levine msl321@lehigh.edu

license

http://opensource.org/licenses/gpl-2.0.php GNU General Public License

link
https://vufind.org

Interfaces, Classes, Traits and Enums

OauthServiceInterface
Interface for classes using OauthServiceTrait.
HttpServiceAwareInterface
LoggerAwareInterface

Table of Contents

$baseUrl  : string
Base URL of the LibGuides API
$client  : HttpClient
HTTP Client
$clientId  : string
Client ID for a client_credentials grant
$clientSecret  : string
Client Secret for a client_credentials grant
$tokenData  : stdClass
Current OAuth token
$userAgent  : string
User agent to send in header
__construct()  : mixed
Constructor
authenticateWithClientCredentials()  : stdClass|bool
Authenticate via the OAuth Client Credentials grant type.
getAccounts()  : object|null
Load all LibGuides accounts.
getAZ()  : object|null
Load all LibGuides AZ databases.
authenticateAndSetHeaders()  : bool
Authenticate to the LibGuides API and set authentication headers.
debug()  : void
Log a debug message.
doGet()  : object|null
Perform a GET request to the LibGuides API.
log()  : void
Send a message to the logger.
logError()  : void
Log an error message.
logWarning()  : void
Log a warning message.
oauthServiceTraitDebug()  : void
Log a debug message, if $this->log exists.
oauthServiceTraitError()  : void
Log an error message, if $this->log exists.
oauthServiceTraitLog()  : void
Log a message, if $this->log exists.

Properties

$baseUrl

Base URL of the LibGuides API

protected string $baseUrl

$client

HTTP Client

protected HttpClient $client

$clientId

Client ID for a client_credentials grant

protected string $clientId

$clientSecret

Client Secret for a client_credentials grant

protected string $clientSecret

$userAgent

User agent to send in header

protected string $userAgent = 'VuFind'

Methods

authenticateWithClientCredentials()

Authenticate via the OAuth Client Credentials grant type.

public authenticateWithClientCredentials(string $oauthUrl, string $clientId, string $clientSecret) : stdClass|bool
Parameters
$oauthUrl : string

URL of thee OAuth service

$clientId : string

client_id for a client_credentials grant

$clientSecret : string

client_secret for a client_credentials grant

Tags
link
https://www.oauth.com/oauth2-servers/access-tokens/client-credentials/
Return values
stdClass|bool

token for the session or false if the token request failed

getAccounts()

Load all LibGuides accounts.

public getAccounts() : object|null
Return values
object|null

A JSON object of all LibGuides accounts, or null if an error occurs

getAZ()

Load all LibGuides AZ databases.

public getAZ() : object|null
Return values
object|null

A JSON object of all LibGuides databases, or null if an error occurs

authenticateAndSetHeaders()

Authenticate to the LibGuides API and set authentication headers.

protected authenticateAndSetHeaders() : bool
Return values
bool

Indicates if authentication succeeded.

debug()

Log a debug message.

protected debug(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

doGet()

Perform a GET request to the LibGuides API.

protected doGet(string $url) : object|null
Parameters
$url : string

Full request url

Return values
object|null

A JSON object of the response data, or null if an error occurs

log()

Send a message to the logger.

protected log(string $level, string $message[, array<string|int, mixed> $context = [] ][, bool $prependClass = false ]) : void
Parameters
$level : string

Log level

$message : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = false

Prepend class name to message?

Return values
void

logError()

Log an error message.

protected logError(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

logWarning()

Log a warning message.

protected logWarning(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

oauthServiceTraitDebug()

Log a debug message, if $this->log exists.

protected oauthServiceTraitDebug(string $msg) : void
Parameters
$msg : string

Log message

Return values
void

oauthServiceTraitError()

Log an error message, if $this->log exists.

protected oauthServiceTraitError(string $msg) : void
Parameters
$msg : string

Log message

Return values
void

oauthServiceTraitLog()

Log a message, if $this->log exists.

protected oauthServiceTraitLog(string $level, string $msg) : void
Parameters
$level : string

Logging level

$msg : string

Log message

Return values
void

Search results