function google_cse_adv_service in Google Custom Search Engine 7.2
Sends query to Google's Custom Search Engine and returns response.
Parameters
string $keys: The search terms.
int $offset: The result number to start at.
Return value
string XML response string.
2 calls to google_cse_adv_service()
- google_cse_adv_get_accurate_num_of_results in google_cse_adv/
google_cse_adv.inc - Get the exact (accurate) number of search results to be used in the pager.
- google_cse_search_execute in ./
google_cse.module - Implements hook_search_execute().
File
- google_cse_adv/
google_cse_adv.inc, line 25 - Uses Google Custom Search Engine (CSE) without frames and ads.
Code
function google_cse_adv_service($keys, $offset = 0) {
$page = 0;
$response = array();
if (isset($_GET['page'])) {
$page = $_GET['page'];
}
if (isset($response[$keys])) {
return $response[$keys];
}
// Number of results per page. 10 is the default for Google CSE.
$rows = (int) variable_get('google_cse_adv_results_per_page', 10);
$query = array(
'cx' => variable_get('google_cse_cx', ''),
'client' => 'google-csbe',
'output' => 'xml_no_dtd',
'filter' => '1',
'hl' => google_cse_adv_param_hl(),
'lr' => google_cse_adv_param_lr(),
'q' => $keys,
'num' => $rows,
'start' => $offset ? $offset : $page * $rows,
'as_sitesearch' => variable_get('google_cse_limit_domain', ''),
);
if (isset($_GET['more'])) {
$query['+more:'] = urlencode($_GET['more']);
}
$url = url('http://www.google.com/cse', array(
'query' => $query,
));
// Get the google response.
$response = google_cse_adv_get_response($url);
return $response;
}