url = 'http://api.local.yahoo.com/MapsService/V1/geocode?appid=[your yahoo app id]&location='; $this->data = Array(); } public function geocode($location) { $this->url .= rawurlencode($location); $ch = curl_init($this->url); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $xml_stream = curl_exec($ch); curl_close($ch); $xml = simplexml_load_string($xml_stream); if ($xml) { if (empty($xml->Message)) { $this->url .= '&output=php'; $data = file_get_contents($this->url); if ($data) { $data = unserialize($data); } else { throw new Exception('The PHP object could not be read.'); } } else { $data = $xml->Message; } return $data; } else { throw new Exception('The XML stream could not be read.'); } } } ?>