You are here

protected static function clients_connection_base::doCall in Web Service Clients 7

Takes variable number of params after cacheid.

2 calls to clients_connection_base::doCall()
clients_connection_drupal_services::fetch in backends/clients_drupal/clients_drupal.inc
Gets raw data from service call
clients_connection_flickr::call in backends/clients_flickr/clients_flickr.inc
Executes call and processes data

File

./clients.inc, line 45
Base class for backends. Handles XML-RPC, REST calls and caching results

Class

clients_connection_base
Base class for Client connections.

Code

protected static function doCall($method, $cacheid) {
  $args = func_get_args();
  $args = array_slice($args, 2);

  // any extra params passed to this argument
  $cache_table = 'cache_clients';
  $cache_time = variable_get('clients_api_cache_time', '0');
  if ($cache_time == '0' || !($result = cache_get($cacheid, $cache_table))) {
    if ($method == 'xmlrpc') {
      $data = call_user_func_array('xmlrpc', $args);
    }
    elseif ($method == 'rest') {
      $data = call_user_func_array('drupal_http_request', $args);
    }
    else {
      $data = t('@method not yet supported', array(
        '@method' => $method,
      ));
    }

    // @todo error handling/reporting
    if ($cache_time != '0') {
      cache_set($cacheid, $data, $cache_table, $cache_time == 'cron' ? CACHE_TEMPORARY : time() + (int) $cache_time * 60);
    }
    $result = new stdClass();
    $result->data = $data;
    $result->created = time();
  }
  return $result;
}