You are here

function _acquia_agent_request in Acquia Connector 7.3

Same name and namespace in other branches
  1. 6.2 acquia_agent/acquia_agent_streams.inc \_acquia_agent_request()
  2. 6 acquia_agent/acquia_agent_streams.inc \_acquia_agent_request()
  3. 7 acquia_agent/acquia_agent.module \_acquia_agent_request()
  4. 7.2 acquia_agent/acquia_agent.module \_acquia_agent_request()

Send a XML-RPC request.

This function should never be called directly - use acquia_agent_call().

Parameters

string $url: Url.

string $method: Method.

array $data: Data.

Return value

array|bool Request status.

3 calls to _acquia_agent_request()
acquia_agent_automatic_setup_form_validate in acquia_agent/acquia_agent.pages.inc
Needs comment.
acquia_agent_call in acquia_agent/acquia_agent.module
Prepare and send a XML-RPC request to Acquia Insight with an authenticator.
_acquia_agent_automatic_start_submit in acquia_agent/acquia_agent.pages.inc
Needs comment.

File

acquia_agent/acquia_agent.module, line 819
Acquia Agent securely sends information to Acquia Insight.

Code

function _acquia_agent_request($url, $method, array $data) {
  if (function_exists('acquia_connector_test_xmlrpc_server_emulator')) {
    return acquia_connector_test_xmlrpc_server_emulator($method, $data);
  }
  $ctx = acquia_agent_stream_context_create($url);
  if (!$ctx) {

    // TODO: what's a meaningful fault code?
    xmlrpc_error(-1, t('SSL is not supported or setup failed'));
    $result = FALSE;
  }
  else {
    $result = xmlrpc($url, array(
      $method => array(
        $data,
      ),
    ), array(
      'context' => $ctx,
    ));
  }
  if ($errno = xmlrpc_errno()) {
    $acquia_debug = variable_get('acquia_agent_debug', FALSE);
    if ($acquia_debug) {
      watchdog('acquia agent', '@message (@errno): %server - %method - <pre>@data</pre>', array(
        '@message' => xmlrpc_error_msg(),
        '@errno' => xmlrpc_errno(),
        '%server' => $url,
        '%method' => $method,
        '@data' => var_export($data, TRUE),
      ), WATCHDOG_ERROR);
    }
    else {
      watchdog('acquia agent', '@message (@errno): %server - %method', array(
        '@message' => xmlrpc_error_msg(),
        '@errno' => xmlrpc_errno(),
        '%server' => $url,
        '%method' => $method,
      ), WATCHDOG_ERROR);
    }
    $result = FALSE;
  }
  return $result;
}