You are here

function _curl_post in Google Search Appliance 7

Send a POST requst using cURL

Parameters

string $url to request:

array $post values to send:

array $options for cURL:

Return value

string

1 call to _curl_post()
google_appliance_get_clusters in ./google_appliance.module
get related search via the Google Search Appliance clustering service

File

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

Code

function _curl_post($url, array $post = NULL, array $options = array()) {
  $defaults = array(
    CURLOPT_POST => 1,
    CURLOPT_HEADER => 0,
    CURLOPT_URL => $url,
    CURLOPT_FRESH_CONNECT => 1,
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_FORBID_REUSE => 1,
    CURLOPT_TIMEOUT => 4,
    CURLOPT_POSTFIELDS => http_build_query($post, '', '&'),
  );
  $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;
}