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;
}
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_foodspotting_get_place($place_id)
{
    $cache_key = "enplacify_foodspotting_place_{$place_id}";
    $cache = cache_get($cache_key);
    if ($cache['ok']) {
        return $cache['data'];
    }
    $url = "http://www.foodspotting.com/places/" . urlencode($place_id);
    $http_rsp = http_get($url);
    if (!$http_rsp['ok']) {
        return $http_rsp;
    }
    $rsp = vcard_parse_html($http_rsp['body']);
    if ($rsp['ok']) {
        $place = $rsp['vcard'];
        $place['id'] = $place_id;
        # vcard has no specifics for latlon so just assume this is false and look for:
        # <input id="place_latitude" name="place[latitude]" type="hidden" value="35.6633801" />
        # <input id="place_longitude" name="place[longitude]" type="hidden" value="139.71029
        $has_latlon = 0;
        libxml_use_internal_errors(true);
        $doc = new DOMDocument();
        $html = mb_convert_encoding($http_rsp['body'], 'html-entities', 'utf-8');
        if ($doc->loadHTML($html)) {
            foreach ($doc->getElementsByTagName('input') as $i) {
                $id = $i->getAttribute('id');
                if (preg_match("/place_(latitude|longitude)/", $id, $m)) {
                    $place[$m[1]] = $i->getAttribute('value');
                }
            }
            $has_latlon = $place['latitude'] && $place['longitude'] ? 1 : 0;
        }
        if (!$has_latlon && ($place['street-address'] && $place['locality'] && $place['region'])) {
            $q = "{$place['street-address']}, {$place['locality']} {$place['region']}";
            $geo_rsp = geo_geocode_string($q);
            if ($geo_rsp['ok']) {
                $place['latitude'] = $geo_rsp['latitude'];
                $place['longitude'] = $geo_rsp['longitude'];
            }
        }
        $rsp = array('ok' => 1, 'place' => $place);
    }
    cache_set($cache_key, $rsp);
    return $rsp;
}