function enplacify_chowhound_get_restaurant($restaurant_id) { $cache_key = "enplacify_chowhound_restaurant_{$restaurant_id}"; $cache = cache_get($cache_key); if ($cache['ok']) { return $cache['data']; } $url = "http://www.chow.com/restaurants/" . urlencode($restaurant_id); $headers = array(); $more = array('follow_redirects' => 1); $rsp = http_get($url, $headers, $more); if (!$rsp['ok']) { return $rsp; } $vcard_rsp = vcard_parse_html($rsp['body']); $graph_rsp = opengraph_parse_html($rsp['body']); if (!$vcard_rsp['ok'] && !$graph_rsp['ok']) { $rsp = array('ok' => 0, 'error' => 'Failed to parse restaurant'); } else { $restaurant = array_merge($vcard_rsp['vcard'], $graph_rsp['graph']); $restaurant['id'] = $restaurant_id; $rsp = array('ok' => 1, 'restaurant' => $restaurant); } cache_set($cache_key, $rsp); return $rsp; }
function enplacify_yelp_get_listing($listing_id) { $cache_key = "enplacify_yelp_listing_{$listing_id}"; $cache = cache_get($cache_key); if ($cache['ok']) { return $cache['data']; } $url = "http://www.yelp.com/biz/" . urlencode($listing_id); $headers = array(); $more = array('follow_redirects' => 1); $rsp = http_get($url, $headers, $more); if (!$rsp['ok']) { return $rsp; } $vcard_rsp = vcard_parse_html($rsp['body']); $graph_rsp = opengraph_parse_html($rsp['body']); if (!$vcard_rsp['ok'] && !$graph_rsp['ok']) { $rsp = array('ok' => 0, 'error' => 'Failed to parse listing'); } else { $listing = array_merge($vcard_rsp['vcard'], $graph_rsp['graph']); $listing['id'] = $listing_id; $rsp = array('ok' => 1, 'listing' => $listing); } cache_set($cache_key, $rsp); return $rsp; }