75 private ?HTTPMessage
$http = null;
130 public function send(
string $method, array $parameters = array(),
string $body = null): ?HTTPMessage
133 if (!empty($parameters)) {
134 if (strpos(
$url,
'?') ===
false) {
139 foreach ($parameters as
$name => $value) {
140 $url .= $sep . urlencode(
$name) .
'=' . urlencode($value);
145 $retry = !$this->platform->useOAuth1();
149 if (!$this->
unsigned) {
150 $accessToken = $this->platform->getAccessToken();
151 if (!$this->platform->useOAuth1()) {
152 if (empty($accessToken)) {
154 $this->platform->setAccessToken($accessToken);
156 if (!$accessToken->hasScope($this->scope)) {
157 $accessToken->get($this->scope);
159 if (!$accessToken->hasScope($this->scope)) {
160 $accessToken->expires = time();
161 $accessToken->get($this->scope,
true);
163 if (!$accessToken->hasScope($this->scope)) {
164 if (empty($this->
http)) {
165 $this->
http =
new HttpMessage(
$url);
166 $this->
http->error =
"Unable to obtain an access token for scope: {$this->scope}";
173 $header = $this->platform->signServiceRequest(
$url, $method, $this->mediaType, $body);
179 $this->
http = new \ILIAS\LTI\ToolProvider\Http\HttpMessage(
$url, $method, $body, $header);
180 if ($this->
http->send() && !empty($this->
http->response)) {
181 $this->
http->responseJson = json_decode($this->
http->response);
182 $this->
http->ok = !is_null($this->
http->responseJson);
184 $retry = $retry && !$retried && !$this->
http->ok;
187 $accessToken->expires = time();
189 } elseif (count($accessToken->scopes) !== 1) {
190 $accessToken->expires = time();
191 $accessToken->get($this->scope,
true);
213 ### PROTECTED METHODS 224 if (is_array($contexts)) {
225 $contextdefs = array();
227 if (is_object($context)) {
228 $contextdefs = array_merge(get_object_vars($context), $contexts);
232 foreach ($arr as
$key => $value) {
233 $parts = explode(
':', $value, 2);
235 if (array_key_exists(
$parts[0], $contextdefs)) {
240 $parsed[
$key] = $value;
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
static http()
Fetches the global http state from ILIAS.