public function getAddressData($address) { $key = $this->language . ":" . $address; $location = $this->cache->get($key); if (empty($location)) { // ベースURLを取得 $baseUrl = "http://maps.google.com/maps/api/geocode/json?sensor=false&address="; // 追加ヘッダ情報を設定 $options = array("http" => array("header" => "Accept-Language: " . $this->language)); $context = stream_context_create($options); // コンテンツを取得 if (preg_match("/^([^0-9]+)([0-9]+)?([^0-9]*[0-9]+)?([^0-9]*[0-9]+)?/", mb_convert_kana($address, "n"), $p) > 0) { $address = $p[0]; } $location = file_get_contents($baseUrl . urlencode($address), false, $context); $this->cache->set($key, $location); } $data = json_decode($location); if ($data->status == "OK") { return $data->results; } else { return array(); } }