You are here

public function EntityShareClient::call in Entity Share 7

Make an API call.

Parameters

string $url: URL of the request.

string $method: HTTP method of the request.

mixed $datas: Data of the request.

Return value

object Object of the response.

5 calls to EntityShareClient::call()
EntityShareClient::create in includes/entity_share.client.inc
Create an entity.
EntityShareClient::delete in includes/entity_share.client.inc
Delete an entity.
EntityShareClient::get in includes/entity_share.client.inc
Get an entity.
EntityShareClient::login in includes/entity_share.client.inc
Login to the remote server.
EntityShareClient::update in includes/entity_share.client.inc
Update an entity.

File

includes/entity_share.client.inc, line 125
Class for handling communication with Entity Share Server.

Class

EntityShareClient
Entity Share Client class.

Code

public function call($url, $method, $datas = NULL) {
  $options = array(
    'headers' => array(
      'Content-Type' => 'application/json',
      'Accept' => 'application/json',
    ),
    'method' => $method,
    'data' => is_null($datas) ? '' : $datas,
  );

  // Add authentication information.
  if (!empty($this->sessionDatas)) {
    $options['headers']['Cookie'] = $this->sessionDatas['session_name'] . '=' . $this->sessionDatas['session_id'];
  }
  drupal_alter(self::HOOK_PREFIX . 'call_options', $options);
  $this->lastResponse = drupal_http_request($url, $options);
  if (self::$debug) {
    watchdog(self::WATCHDOG_TYPE, '@url @method response => @response', array(
      '@url' => $url,
      '@method' => $method,
      '@response' => drupal_json_encode($this->lastResponse),
    ));
  }
  return $this->lastResponse;
}