PHP code example of openlrw / api-client

1. Go to this page and download the library: Download openlrw/api-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

openlrw / api-client example snippets


use OpenLRW\OpenLRW;

$client = new OpenLRW(URL, KEY, PASSWORD);

$isServerUp = OpenLRW::isUp();

OpenLRW::generateJwt();

// Get and edit a user
$user = User::find('foobar');
$user->status = 'active';
$user->save();


// Create a new user
$user = new User();
$user->sourcedId = 'foo';
$user->name = 'bar';
$user->status 'inactive';
$user->save();

// Delete a user
$user->delete(); /** or */ User::destroy('foo-bar');

// Get all the users
$users = Users::all(); 

/** Klass model */
$enrollments = Klass::enrollments($classId); // array
$events = Klass::events($classId); // array
// ...

/** Risk */
$latestRisk = Risk::latestByClassAndUser($classId, $userId); // Risk::class
// ...


$user = OneRoster::httpGet('users/test2u'); // return an array

$jsonInArray = ['...'];
$response = OneRoster::httpPost('users', $jsonInArray);
bash
\vendor\bin\phpunit.bat --bootstrap vendor\autoload.php  tests\ApiClientTest.php