public function GoogleMini::query in Google Search Appliance 6.2
Same name and namespace in other branches
- 5 GoogleMini.php \GoogleMini::query()
1 call to GoogleMini::query()
1 method overrides GoogleMini::query()
File
- ./
GoogleMini.php, line 296
Class
Code
public function query($iteratorClass = 'GoogleMiniResultIterator') {
$query = $this
->buildQuery();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $query);
// Set the query URL.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
// Return the response during the curl_exec() call, or FALSE on error.
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
// Output errors to STDERR
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
// Allow the cURL request to succeed even if the Google Mini server's SSL certificate isn't valid.
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
// This way, you can serve the Google Mini using https without having to maintain an SSL certficate.
// Set this to a large number if connections aren't being made. Set to 0 for infinite timeout.
if ($timeout = variable_get('google_appliance_timeout', FALSE)) {
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
}
// send request
$resultXML = curl_exec($ch);
if ($this->debug) {
$this
->log('Made cURL request to ' . $query);
}
// handle errors if cURL request fails
if (!$resultXML) {
if ($this->debug) {
$this
->log('cURL error #' . curl_errno($ch) . ': ' . curl_error($ch));
}
throw new GoogleMiniResultException('There was a cURL error while connecting with the Google device.');
return FALSE;
}
// if request succeeded, return formatted result set
return self::resultFactory($resultXML, $iteratorClass);
}