public function index()
{
$url = $this->get_uriPath();
$google = json_decode($this->get_map( str_replace("?", "", str_replace("\r\n", "", $url[1]) )));
$gpoint = array();
foreach($google as $k) {
$gpoint['x'] = $k->items[0]->point->x;
$gpoint['y'] = $k->items[0]->point->y;
}
echo json_encode($gpoint);
}
function get_map($addr)
{
$ch = curl_init();
$address = $addr;
$encoding="utf-8"; //출력 결과 인코딩 값으로 'utf-8', 'euc-kr' 가능
$coord="latlng"; //출력 좌표 체계 값으로 latlng(위경도), tm128(카텍) 가능
$output="json" ;//json,xml
$qry_str = "?encoding=".$encoding."&coord=".$coord."&output=".$output."&query=".$address;
$headers = array(
"X-Naver-Client-Id: 네이버발급", //Client ID
"X-Naver-Client-Secret: 네이버발급" //Client Secret
);
$url="https://openapi.naver.com/v1/map/geocode";
curl_setopt($ch, CURLOPT_URL, $url.$qry_str);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($ch);
curl_close($ch);
return $res;
}
function get_uriParse()
{
$url = $_SERVER['SERVER_NAME'];
$parse_url = explode(".", $url);
return $parse_url[0];
}
function get_uriPath() {
$querystring = $_SERVER['REQUEST_URI'];
return $parse_query = explode("/?", $querystring);
}