You are here

function _curl_get in Google Search Appliance 7

Send a GET requst using cURL

Parameters

string $url to request:

array $get values to send:

array $options for cURL:

Return value

string

1 call to _curl_get()
google_appliance_search_view in ./google_appliance.module
Top level search execution (menu callback)

File

./google_appliance.helpers.inc, line 134
helper functions for the Search Google Appliance module

Code

function _curl_get($url, array $get = NULL, array $options = array(), $sga_timeout = 30) {
  $defaults = array(
    CURLOPT_URL => $url . (strpos($url, '?') === FALSE ? '?' : '') . http_build_query($get, '', '&'),
    CURLOPT_HEADER => 0,
    CURLOPT_RETURNTRANSFER => TRUE,
    CURLOPT_TIMEOUT => check_plain($sga_timeout),
  );
  $ch = curl_init();
  curl_setopt_array($ch, $options + $defaults);
  $result = array(
    'is_error' => FALSE,
    'response' => curl_exec($ch),
  );
  if ($result['response'] === FALSE) {
    $result['is_error'] = TRUE;
    $result['response'] = curl_error($ch);
  }
  curl_close($ch);
  return $result;
}