You must specify a search type such as "app" or "podcast". Check the url to make sure "type=" has a value.';
exit;
}
if(isset($_GET['q'])):
//if Google Ajax Search API has been queried using the form
//check and assign page of search results - are we on the first page?
$start = isset($_GET['start']) ? $_GET['start'] : 0;
echo '
Try another search?
'."\n";
//set URL for the Google Ajax Search API
$url = 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q='.urlencode($query).'%20site:'.$site.'&rsz=large&start='.$start;
//build request and send to Google Ajax Search API
$request = file_get_contents($url);
//decode json object(s) out of response from Google Ajax Search API
$body = json_decode($request);
//create an array for search results
$i = 0;
$search_results = array();
//loop through all results
foreach ($body->responseData->results as $item) {
$search_results['results'][$i]['title'] = $item->title;
$search_results['results'][$i]['url'] = $item->url;
$search_results['results'][$i]['content'] = $item->content;
$i++;
}
//loop through all the pages of results
if(isset($body->responseData->cursor->pages)) {
foreach($body->responseData->cursor->pages as $p) {
$search_results['pages'][] = $p->start;
}
}
//make sure some results were returned, show results as html with result numbering and pagination
if(isset($search_results['results'])) {
?>
Results of your iTunes "" search for "" (About responseData->cursor->estimatedResultCount; ?> matches)
0 ? ' start="' .($_GET['start'] + 1) .'"' : '' ?>>
-
more
Sorry, there were no results
API request: '.$apiRequest.'';
?>