3 declare(strict_types=1);
47 GuzzleHttp\RequestOptions::VERIFY =>
true,
48 GuzzleHttp\RequestOptions::CONNECT_TIMEOUT => 10,
49 GuzzleHttp\RequestOptions::HTTP_ERRORS =>
false 53 'Authorization' => $this->basicAuth,
54 'X-Experience-API-Version' =>
'1.0.3' 59 $promises[
'default'] =
$client->sendAsync($request, $req_opts);
60 $responses = GuzzleHttp\Promise\Utils::settle($promises)->wait();
61 self::checkResponse($responses[
'default'], $body);
65 throw new Exception(
"LRS Connection Problems", $e->getCode(),
$e);
72 if ($response[
'state'] ==
'fulfilled') {
73 $status = $response[
'value']->getStatusCode();
74 if (in_array($status, $allowedStatus)) {
75 $body = $response[
'value']->getBody()->getContents();
78 ilObjCmiXapi::log()->error(
"LRS error: " . $response[
'value']->getBody()->getContents());
83 ilObjCmiXapi::log()->error(
"Connection error: " . $response[
'reason']->getMessage());
98 if ($encoding ===
false) {
99 $encoder = fn ($str) => $str;
100 } elseif ($encoding === PHP_QUERY_RFC3986) {
101 $encoder =
'rawurlencode';
102 } elseif ($encoding === PHP_QUERY_RFC1738) {
103 $encoder =
'urlencode';
105 throw new \InvalidArgumentException(
'Invalid type');
109 foreach ($params as $k => $v) {
114 $qs .=
'=' . $encoder($v);
118 foreach ($v as $vv) {
121 $qs .=
'=' . $encoder($vv);
127 return $qs ? (string) substr($qs, 0, -1) :
'';
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
__construct(string $basicAuth)
ilCmiXapiAbstractRequest constructor.
static buildQuery(array $params, $encoding=PHP_QUERY_RFC3986)
static checkResponse(array $response, &$body, array $allowedStatus=[200, 204])