@@ -52,14 +52,51 @@ public static string GeocodeResponse(HttpListenerRequest request)
5252 if ( inputId == null || inputId . Equals ( String . Empty ) ) inputId = Constants . NAVER_SB_ID ;
5353 string inputKey = queryCollection . Get ( "key" ) ;
5454 if ( inputKey == null || inputKey . Equals ( String . Empty ) ) inputKey = Constants . NAVER_SB_KEY ;
55+ string [ ] inputAddressArray ;
5556 string inputAddress = queryCollection . Get ( "address" ) ;
57+ if ( inputAddress == null || inputAddress . Equals ( String . Empty ) ) inputAddress = "" ;
58+ inputAddressArray = inputAddress . Split ( '|' ) ;
5659 string inputCoordinate = queryCollection . Get ( "coordinate" ) ;
57- string requestURL = $ "https://naveropenapi.apigw.ntruss.com/map-geocode/v2/geocode?query={ inputAddress } &coordinate={ inputCoordinate } ";
60+ if ( inputCoordinate == null || inputCoordinate . Equals ( String . Empty ) ) inputCoordinate = "" ;
61+
62+ string [ ] headerId ;
63+ string [ ] headerKey ;
64+ string [ ] headerAddress ;
65+ string [ ] headerCoordinate ;
66+ headerId = request . Headers . GetValues ( "id" ) ;
67+ if ( headerId != null && headerId . Length > 0 )
68+ {
69+ inputId = headerId [ 0 ] ;
70+ }
71+ headerKey = request . Headers . GetValues ( "key" ) ;
72+ if ( headerKey != null && headerKey . Length > 0 )
73+ {
74+ inputKey = headerKey [ 0 ] ;
75+ }
76+ headerAddress = request . Headers . GetValues ( "address" ) ;
77+ if ( headerAddress != null && headerAddress . Length > 0 )
78+ {
79+ inputAddressArray = headerAddress ;
80+ }
81+ headerCoordinate = request . Headers . GetValues ( "coordinate" ) ;
82+ if ( headerCoordinate != null && headerCoordinate . Length > 0 )
83+ {
84+ inputCoordinate = headerCoordinate [ 0 ] ;
85+ }
86+
87+ JArray naverGeocodeResultArray = new JArray ( ) ;
5888 WebClient naverGeocodeClient = new WebClient { Encoding = Encoding . UTF8 } ;
5989 naverGeocodeClient . Headers . Add ( "X-NCP-APIGW-API-KEY-ID" , inputId ) ;
6090 naverGeocodeClient . Headers . Add ( "X-NCP-APIGW-API-KEY" , inputKey ) ;
61- String naverGeocodeResult = naverGeocodeClient . DownloadString ( requestURL ) ;
62- return naverGeocodeResult ;
91+
92+ for ( int i = 0 ; i < inputAddressArray . Length ; i ++ )
93+ {
94+ string requestURL = $ "https://naveropenapi.apigw.ntruss.com/map-geocode/v2/geocode?query={ inputAddressArray [ i ] } &coordinate={ inputCoordinate } ";
95+ JObject resultObject = JObject . Parse ( naverGeocodeClient . DownloadString ( requestURL ) ) ;
96+ naverGeocodeResultArray . Add ( resultObject ) ;
97+ }
98+
99+ return naverGeocodeResultArray . ToString ( ) ;
63100 }
64101
65102 public static string ZeroPayResponse ( HttpListenerRequest request )
0 commit comments