nestoria_keyword($key, $show_xml = FALSE)
nestoria/nestoria.module, line 65
Call based on keywords
function nestoria_keyword($key, $show_xml = FALSE) {
$cache = cache_get('nestoria:'. $key, 'cache');
if (empty($cache->data)) {
print 'live data';
$url = 'http://api.nestoria.es/api?action=search_listings&encoding=xml&place_name=Barcelona&keywords='. $key;
$data = drupal_http_request($url);
$xml_data = simplexml_load_string($data->data);
$xml = _nestoria_simplexml2array($xml_data);
$info = $xml['response'];
cache_set('nestoria:'. $key, 'cache', serialize($info), time() + (3600 * 24));
}
else {
$info = unserialize($cache->data);
}
if (!$show_xml) {
$output = l(t('Show XML'), 'nestoria/keyword/'. $key .'/1');
$summary = $info['@attributes'];
$listings = $info['listings'];
$output .= theme('nestoria_summary', $summary);
$header = array();
$rows = array();
foreach ($listings as $listing) {
$rows[] = theme('nestoria_listing', $listing['@attributes']);
}
$output .= theme('table', $header, $rows);
}
else {
$output = l(t('Show Table'), 'nestoria/keyword/'. $key);
$output .= '<pre>';
$output .= print_r($info, TRUE);
$output .= '</pre>';
}
return $output;
}