34 include_once(
'Services/WebServices/ECS/classes/class.ilECSSettings.php');
35 include_once(
'Services/WebServices/ECS/classes/class.ilECSResult.php');
36 include_once(
'Services/WebServices/Curl/classes/class.ilCurlConnection.php');
77 $ilLog->write(__METHOD__.
': Add new Auth resource...');
79 $this->path_postfix =
'/auths';
84 $this->curl->setOpt(CURLOPT_POST,
true);
85 $this->curl->setOpt(CURLOPT_POSTFIELDS,$a_post);
88 $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
90 $ilLog->write(__METHOD__.
': Checking HTTP status...');
91 if($info != self::HTTP_CODE_CREATED)
93 $ilLog->write(__METHOD__.
': Cannot create auth resource, did not receive HTTP 201. ');
94 $ilLog->write(__METHOD__.
': POST was: '.$a_post);
95 $ilLog->write(__METHOD__.
': HTTP code: '.$info);
98 $ilLog->write(__METHOD__.
': ... got HTTP 201 (created)');
120 $ilLog->write(__METHOD__.
': No auth hash given. Aborting.');
124 $this->path_postfix =
'/auths/'.$a_hash;
131 $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
133 $ilLog->write(__METHOD__.
': Checking HTTP status...');
134 if($info != self::HTTP_CODE_OK)
136 $ilLog->write(__METHOD__.
': Cannot get auth resource, did not receive HTTP 200. ');
139 $ilLog->write(__METHOD__.
': ... got HTTP 200 (ok)');
162 $this->path_postfix =
'/eventqueues';
170 $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
172 $ilLog->write(__METHOD__.
': Checking HTTP status...');
173 if($info != self::HTTP_CODE_OK)
175 $ilLog->write(__METHOD__.
': Cannot get event queue, did not receive HTTP 200. ');
178 $ilLog->write(__METHOD__.
': ... got HTTP 200 (ok)');
208 $ilLog->write(__METHOD__.
': Get resource with ID: '.$a_econtent_id);
212 $ilLog->write(__METHOD__.
': Get all resources ...');
216 $this->path_postfix =
'/econtents';
219 $this->path_postfix .= (
'/'.(int) $a_econtent_id);
225 $this->curl->setOpt(CURLOPT_HEADER,
false);
228 $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
231 $result->setHTTPCode($info);
254 $ilLog->write(__METHOD__.
': Add new EContent...');
256 $this->path_postfix =
'/econtents';
261 $this->curl->setOpt(CURLOPT_HEADER,
true);
262 $this->curl->setOpt(CURLOPT_POST,
true);
263 $this->curl->setOpt(CURLOPT_POSTFIELDS,$a_post);
266 $info = $this->curl->getInfo(CURLINFO_HTTP_CODE);
268 $ilLog->write(__METHOD__.
': Checking HTTP status...');
269 if($info != self::HTTP_CODE_CREATED)
271 $ilLog->write(__METHOD__.
': Cannot create econtent, did not receive HTTP 201. ');
274 $ilLog->write(__METHOD__.
': ... got HTTP 201 (created)');
276 $headers = $result->getHeaders();
278 include_once(
'./Services/WebServices/ECS/classes/class.ilECSUtils.php');
299 $ilLog->write(__METHOD__.
': Update resource with id '.$a_econtent_id);
301 $this->path_postfix =
'/econtents';
305 $this->path_postfix .= (
'/'.(int) $a_econtent_id);
314 $this->curl->setOpt(CURLOPT_PUT,
true);
317 $ilLog->write(__METHOD__.
': Created new tempfile: '.$tempfile);
319 $fp = fopen($tempfile,
'w');
320 fwrite($fp,$a_post_string);
323 #$this->curl->setOpt(CURLOPT_POSTFIELDS,$a_post_string);
325 $this->curl->setOpt(CURLOPT_UPLOAD,
true);
326 $this->curl->setOpt(CURLOPT_INFILESIZE,filesize($tempfile));
327 $fp = fopen($tempfile,
'r');
328 $this->curl->setOpt(CURLOPT_INFILE,$fp);
351 $ilLog->write(__METHOD__.
': Delete resource with id '.$a_econtent_id);
353 $this->path_postfix =
'/econtents';
357 $this->path_postfix .= (
'/'.(int) $a_econtent_id);
367 $this->curl->setOpt(CURLOPT_CUSTOMREQUEST,
'DELETE');
393 $ilLog->write(__METHOD__.
': Get existing memberships');
395 $this->path_postfix =
'/memberships';
398 $ilLog->write(__METHOD__.
': Read membership with id: '.$a_mid);
399 $this->path_postfix .= (
'/'.(int) $a_mid);
424 $this->curl =
new ilCurlConnection($this->settings->getServerURI().$this->path_postfix);
428 $this->curl->setOpt(CURLOPT_HTTPHEADER,array(0 =>
'Accept: application/json'));
429 $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER,1);
430 $this->curl->setOpt(CURLOPT_SSL_VERIFYHOST,1);
431 $this->curl->setOpt(CURLOPT_RETURNTRANSFER,1);
432 $this->curl->setOpt(CURLOPT_VERBOSE,1);
433 $this->curl->setOpt(CURLOPT_CAINFO,$this->settings->getCACertPath());
434 $this->curl->setOpt(CURLOPT_SSLCERT,$this->settings->getClientCertPath());
435 $this->curl->setOpt(CURLOPT_SSLKEY,$this->settings->getKeyPath());
436 $this->curl->setOpt(CURLOPT_SSLKEYPASSWD,$this->settings->getKeyPassword());
456 $res = $this->curl->exec();