Showing
1 changed file
with
18 additions
and
18 deletions
... | @@ -4,37 +4,24 @@ const convert = require('xml-js'); | ... | @@ -4,37 +4,24 @@ const convert = require('xml-js'); |
4 | 4 | ||
5 | const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' | 5 | const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' |
6 | const TOKEN = 'z5iy5sMU1W4xZAlwvn0/5x4U+4ZsqI0hKO1ZZNFxUGlNzGBjFg2D1u6/Ij5C/Sbkncx3hyYg7Nfz5JnMD8BG/9Z3TEEHPvy1A2XhkPKs04v0/n6TjH1A3e9X23zYdYmNSGyPn2hDGglgm2p3YmtLSwdB04t89/1O/w1cDnyilFU=' | 6 | const TOKEN = 'z5iy5sMU1W4xZAlwvn0/5x4U+4ZsqI0hKO1ZZNFxUGlNzGBjFg2D1u6/Ij5C/Sbkncx3hyYg7Nfz5JnMD8BG/9Z3TEEHPvy1A2XhkPKs04v0/n6TjH1A3e9X23zYdYmNSGyPn2hDGglgm2p3YmtLSwdB04t89/1O/w1cDnyilFU=' |
7 | -const FOODAPI_URL = 'http://apis.data.go.kr/1470000/FoodAdtvInfoService/getFoodAdtvInfoList' | ||
8 | -const FOODAPI_KEY = 'ofY2ppOq5kBqT5jYPaGsW%2BEy7OR5a1bf5Z9PHvqNKvwO5DSCaU2x2qCj%2FoXnuB1YVbMTlErkHWSMEsR5b7isrw%3D%3D'; | ||
9 | -var queryParams = '?' + encodeURIComponent('ServiceKey') + '=' +key; | ||
10 | -//queryParams += '&' + encodeURIComponent('prdlst_cd') + '=' + encodeURIComponent('C0118010300000'); | ||
11 | -queryParams += '&' + encodeURIComponent('pc_kor_nm') + '=' + encodeURIComponent('과.채음료'); | ||
12 | -//queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('3'); | ||
13 | -//queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('100'); | ||
14 | - | ||
15 | -var ProductCategoryName = '스위트초콜릿'; | ||
16 | - | ||
17 | 7 | ||
8 | +var ProductCategoryName ; | ||
18 | var first_url = 'http://apis.data.go.kr/1470000/FoodAdtvInfoService/getFoodAdtvInfoList'; | 9 | var first_url = 'http://apis.data.go.kr/1470000/FoodAdtvInfoService/getFoodAdtvInfoList'; |
19 | var first_key ='ofY2ppOq5kBqT5jYPaGsW%2BEy7OR5a1bf5Z9PHvqNKvwO5DSCaU2x2qCj%2FoXnuB1YVbMTlErkHWSMEsR5b7isrw%3D%3D'; | 10 | var first_key ='ofY2ppOq5kBqT5jYPaGsW%2BEy7OR5a1bf5Z9PHvqNKvwO5DSCaU2x2qCj%2FoXnuB1YVbMTlErkHWSMEsR5b7isrw%3D%3D'; |
11 | +/* | ||
20 | var queryParams1 = '?' + encodeURIComponent('ServiceKey') + '=' +first_key; | 12 | var queryParams1 = '?' + encodeURIComponent('ServiceKey') + '=' +first_key; |
21 | //queryParams1 += '&' + encodeURIComponent('prdlst_cd') + '=' + encodeURIComponent('C0118010300000'); | 13 | //queryParams1 += '&' + encodeURIComponent('prdlst_cd') + '=' + encodeURIComponent('C0118010300000'); |
22 | queryParams1 += '&' + encodeURIComponent('pc_kor_nm') + '=' + encodeURIComponent(ProductCategoryName); | 14 | queryParams1 += '&' + encodeURIComponent('pc_kor_nm') + '=' + encodeURIComponent(ProductCategoryName); |
23 | //queryParams1 += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('213'); | 15 | //queryParams1 += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('213'); |
24 | //queryParams1 += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('100'); | 16 | //queryParams1 += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('100'); |
17 | +*/ | ||
25 | 18 | ||
26 | -var NameOfProduct ='하루견과 요거트S'; // 제품명 넣는 자리 | 19 | +var NameOfProduct ; // 제품명 넣는 자리 |
27 | var second_url ='http://openapi.foodsafetykorea.go.kr/api'; | 20 | var second_url ='http://openapi.foodsafetykorea.go.kr/api'; |
28 | var second_key ='f8ce3271a2dc4decb83b'; | 21 | var second_key ='f8ce3271a2dc4decb83b'; |
29 | var filetype ='json'; | 22 | var filetype ='json'; |
30 | var startIndex = 1; | 23 | var startIndex = 1; |
31 | -var endIndex = 5; | 24 | +var endIndex = 5; |
32 | -var queryParams2 = '/' + encodeURIComponent(second_key); | ||
33 | -queryParams2 += '/' + encodeURIComponent('C002'); | ||
34 | -queryParams2 += '/' + encodeURIComponent(filetype); | ||
35 | -queryParams2 += '/' + encodeURIComponent(startIndex); | ||
36 | -queryParams2 += '/' + encodeURIComponent(endIndex); | ||
37 | -queryParams2 += '/' + encodeURIComponent('PRDLST_NM') + '=' + encodeURIComponent(NameOfProduct); | ||
38 | //var fullRequest = encodeURIComponent("http://openapi.foodsafetykorea.go.kr/api/f8ce3271a2dc4decb83b/C002/xml/1/5/PRDLST_REPORT_NO=200101260032"); | 25 | //var fullRequest = encodeURIComponent("http://openapi.foodsafetykorea.go.kr/api/f8ce3271a2dc4decb83b/C002/xml/1/5/PRDLST_REPORT_NO=200101260032"); |
39 | //var fullRequest ='http://openapi.foodsafetykorea.go.kr/api/f8ce3271a2dc4decb83b/C002/json/1/5'; | 26 | //var fullRequest ='http://openapi.foodsafetykorea.go.kr/api/f8ce3271a2dc4decb83b/C002/json/1/5'; |
40 | 27 | ||
... | @@ -136,6 +123,12 @@ function getfoodinfo(replyToken){ | ... | @@ -136,6 +123,12 @@ function getfoodinfo(replyToken){ |
136 | console.log(body) | 123 | console.log(body) |
137 | }); | 124 | }); |
138 | 125 | ||
126 | + var queryParams2 = '/' + encodeURIComponent(second_key); | ||
127 | + queryParams2 += '/' + encodeURIComponent('C002'); | ||
128 | + queryParams2 += '/' + encodeURIComponent(filetype); | ||
129 | + queryParams2 += '/' + encodeURIComponent(startIndex); | ||
130 | + queryParams2 += '/' + encodeURIComponent(endIndex); | ||
131 | + queryParams2 += '/' + encodeURIComponent('PRDLST_NM') + '=' + encodeURIComponent(replyToken); | ||
139 | request({ | 132 | request({ |
140 | second_url: second_url + queryParams2, | 133 | second_url: second_url + queryParams2, |
141 | //url : fullRequest, | 134 | //url : fullRequest, |
... | @@ -209,6 +202,13 @@ function getfood(replyToken){ | ... | @@ -209,6 +202,13 @@ function getfood(replyToken){ |
209 | console.log(body) | 202 | console.log(body) |
210 | }); | 203 | }); |
211 | 204 | ||
205 | + var queryParams1 = '?' + encodeURIComponent('ServiceKey') + '=' +first_key; | ||
206 | + //queryParams1 += '&' + encodeURIComponent('prdlst_cd') + '=' + encodeURIComponent('C0118010300000'); | ||
207 | + queryParams1 += '&' + encodeURIComponent('pc_kor_nm') + '=' + encodeURIComponent(replyToken); | ||
208 | + //queryParams1 += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('213'); | ||
209 | + //queryParams1 += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('100'); | ||
210 | + | ||
211 | + | ||
212 | request({ | 212 | request({ |
213 | first_url: first_url + queryParams1, | 213 | first_url: first_url + queryParams1, |
214 | method: 'GET' | 214 | method: 'GET' | ... | ... |
-
Please register or login to post a comment