Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
chamilo-lms/vendor/php-xapi/client/doc/client.md

2.0 KiB

Building an xAPI Client

The xAPI client library ships with a builder class which eases the process of creating an instance of an XApiClient class:

use Xabbuh\XApi\Client\XApiClientBuilder;

$builder = new XApiClientBuilder();
$xApiClient = $builder->setBaseUrl('http://example.com/lrs/api')
    ->setVersion('1.0.0')
    ->build();

The builder creates a client for the 1.0.1 API version if you don't set a version.

HTTP Basic Authentication

Use the setAuth() method if access to the LRS resources is protected with HTTP Basic authentication:

use Xabbuh\XApi\Client\XApiClientBuilder;

$builder = new XApiClientBuilder();
$xApiClient = $builder->setBaseUrl('http://example.com/lrs/api')
    ->setAuth('username', 'password')
    ->build();

OAuth1 Authentication

Using the setOAuthCredentials() method, you can configure the client to access OAuth1 protected resources:

use Xabbuh\XApi\Client\XApiClientBuilder;

$builder = new XApiClientBuilder();
$xApiClient = $builder->setBaseUrl('http://example.com/lrs/api')
    ->setOAuthCredentials('consumer-key', 'consumer-secret', 'token', 'token-secret')
    ->build();

Using the APIs

The Experience API consists of four sub APIs: the statements API, the state API, the activity profile API and the agent profile API. A client for each of these APIs can be obtained from the global XApiClient instance:

$statementsApiClient = $xApiClient->getStatementsApiClient();
$stateApiClient = $xApiClient->getStateApiClient();
$activityProfileApiClient = $xApiClient->getActivityProfileApiClient();
$agentProfileApiClient = $xApiClient->getAgentProfileApiClient();

Read the dedicated chapters of the sub APIs to learn how to make use of them:

  1. The Statements API

  2. The State API

  3. The Activity Profile API

  4. The Agent profile API