You are here

function acquia_spi_send_data in Acquia Connector 7.2

Same name and namespace in other branches
  1. 6.2 acquia_spi/acquia_spi.module \acquia_spi_send_data()
  2. 7.3 acquia_spi/acquia_spi.module \acquia_spi_send_data()

Send data to Acquia Insight.

Note, call acquia_spi_send_full_spi() to support SPI response actions.

Parameters

array $spi SPI data. Required parameters:: 'site_key' A SHA1 hash of the Drupal private key. 'spi_data_version' @see acquia_spi_get().

Note, acquia_agent will add authenticator.

Return value

mixed FALSE if no credentials or validation error else full NSPI response array.

3 calls to acquia_spi_send_data()
AcquiaSPITestCase::testAcquiaSPIMessages in acquia_spi/tests/acquia_spi.test
AcquiaSPITestCase::testAcquiaSPISend in acquia_spi/tests/acquia_spi.test
acquia_spi_send_full_spi in acquia_spi/acquia_spi.module
Gather full SPI data and send to Acquia Insight.

File

acquia_spi/acquia_spi.module, line 478
Send site profile information (NSPI) and system data to Acquia Insight.

Code

function acquia_spi_send_data($spi) {

  // Do nothing unless we have credentials.
  if (!acquia_agent_has_credentials()) {
    watchdog('acquia spi', 'Connect your site to a valid Acquia Subscription to send SPI data', array(), WATCHDOG_ERROR);
    return FALSE;
  }

  // acquia_agent_network_address() sets remote server protocol.
  $nspi_server = variable_get('acquia_spi_server', 'https://nspi.acquia.com');

  // Specify version 3 of the RPC, which ommits request parameters in the HMAC.
  $spi['rpc_version'] = 3;
  $response = acquia_agent_call('acquia.nspi.update', $spi, NULL, NULL, $nspi_server);

  // Validate the server response.
  if (!acquia_agent_valid_response($response, acquia_agent_settings('acquia_key'))) {

    // Acquia Agent will have logged error.
    return FALSE;
  }

  // $response contains request authenticator as well as server authenticator
  // under 'result' element so return just the server response 'body' element.
  return $response['result']['body'];
}