182 $this->secret = null;
183 $this->ltiVersion = null;
184 $this->consumerName = null;
185 $this->consumerVersion = null;
186 $this->consumerGuid = null;
187 $this->profile = null;
188 $this->toolProxy = null;
190 $this->
protected =
false;
191 $this->enabled =
false;
192 $this->enableFrom = null;
193 $this->enableUntil = null;
194 $this->lastAccess = null;
196 $this->defaultEmail =
'';
197 $this->created = null;
198 $this->updated = null;
222 $ok = $this->dataConnector->saveToolConsumer($this);
224 $this->settingsChanged =
false;
236 public function delete()
239 return $this->dataConnector->deleteToolConsumer($this);
314 if (
$ok && !is_null($this->enableFrom)) {
315 $ok = $this->enableFrom <= $now;
317 if (
$ok && !is_null($this->enableUntil)) {
318 $ok = $this->enableUntil > $now;
356 if ($value !== $old_value) {
357 if (!empty($value)) {
362 $this->settingsChanged =
true;
399 if ($this->settingsChanged) {
474 $queryParams = array();
475 $queryString = parse_url(
$url, PHP_URL_QUERY);
476 if (!is_null($queryString)) {
477 $queryItems = explode(
'&', $queryString);
478 foreach ($queryItems as $item) {
479 if (strpos($item,
'=') !==
false) {
480 list(
$name, $value) = explode(
'=', $item);
481 $queryParams[urldecode(
$name)] = urldecode($value);
483 $queryParams[urldecode($item)] =
'';
491 $params[
'oauth_callback'] =
'about:blank';
496 $req->sign_request($hmacMethod, $consumer, null);
499 foreach (array_keys($queryParams) as
$name) {
517 if (is_array(
$data)) {
521 $queryParams = array();
522 $queryString = parse_url(
$endpoint, PHP_URL_QUERY);
523 if (!is_null($queryString)) {
524 $queryItems = explode(
'&', $queryString);
525 foreach ($queryItems as $item) {
526 if (strpos($item,
'=') !==
false) {
527 list(
$name, $value) = explode(
'=', $item);
528 $queryParams[urldecode(
$name)] = urldecode($value);
530 $queryParams[urldecode($item)] =
'';
536 if (!is_array(
$data)) {
538 $hash = base64_encode(sha1(
$data,
true));
539 $params[
'oauth_body_hash'] = $hash;
546 $oauthReq->sign_request($hmacMethod, $oauthConsumer, null);
547 $params = $oauthReq->get_parameters();
549 foreach (array_keys($queryParams) as
$name) {
553 if (!is_array(
$data)) {
554 $header = $oauthReq->to_header();
557 $header .=
"\nAccept: {$type}";
559 }
else if (isset(
$type)) {
560 $header .=
"\nContent-Type: {$type}";
588 if ($http->send() && !empty($http->response)) {
589 $http->responseJson = json_decode($http->response);
590 $http->ok = !is_null($http->responseJson);
610 $toolConsumer->initialize();
611 $toolConsumer->setRecordId(
$id);
613 $toolConsumer->initialize();
616 return $toolConsumer;
637 $ok = $this->dataConnector->loadToolConsumer($this);
639 $this->enabled = $autoEnable;
static from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=null)
pretty much a helper function to set up the request
Class to represent an OAuth Consumer.
Class to represent an HTTP message.
Class to represent an OAuth HMAC_SHA1 signature method.