Merge branch 'api' into 'master'
Api See merge request !1
Showing
3 changed files
with
67 additions
and
6 deletions
express/app2.js
0 → 100644
1 | +var express = require('express'); | ||
2 | +const request = require('request'); | ||
3 | +const api_url = 'http://apis.data.go.kr/1471000/FoodAdtvInfoService/getFoodAdtvInfoList?'; | ||
4 | +//발급받은 키 | ||
5 | +const key = 'PFs%2BxbmfLdZwXaK7l5l9w4xEcdaDcYByiEj9PoHq2KCPAtx%2FE1N7OPUaCPr6bam18nVQgKOnuxMlaRsJhG6gyQ%3D%3D' | ||
6 | + | ||
7 | +const a_url = api_url +'ServiceKey='+key+'&numOfRows=3&pageNo=4'; | ||
8 | + | ||
9 | +console.log(a_url); | ||
10 | + | ||
11 | + | ||
12 | +request(a_url, function(error, response, body){ | ||
13 | + if(!error && response.statusCode ==200) | ||
14 | + console.log(body); | ||
15 | +}) | ||
16 | + | ||
17 | +/* | ||
18 | +request.post({ | ||
19 | + url: a_url, | ||
20 | + form:{ | ||
21 | + key:'value', | ||
22 | + } | ||
23 | + | ||
24 | +},(error,respopnse,body) =>{ | ||
25 | + console.log(body) | ||
26 | +}); | ||
27 | +*/ | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
express/chatbot.js
0 → 100644
1 | +const request = require('request'); | ||
2 | +const url = 'https://notify-api.line.me/api/notify'; | ||
3 | +const token = 'BX7LrLUnmQ2QosiYlg5g8BIXKcfraZnFvLqpLhMBjY8'; | ||
4 | +request.post( | ||
5 | + { | ||
6 | + url: url, | ||
7 | + headers: { | ||
8 | + 'Authorization': `Bearer ${token}` | ||
9 | + }, | ||
10 | + form: { | ||
11 | + message: '안녕하세요. 유해물질 알리미 챗봇입니다.', | ||
12 | + stickerPackageId: 1, | ||
13 | + stickerId: 1 | ||
14 | + } | ||
15 | + },(error, response, body) => { | ||
16 | + console.log(body) | ||
17 | + }); |
1 | let request = require('request'); | 1 | let request = require('request'); |
2 | 2 | ||
3 | // REST API 경로 & 요청 메시지 | 3 | // REST API 경로 & 요청 메시지 |
4 | -const url = 'http://apis.data.go.kr/1470000/FoodAdtvInfoService/getFoodAdtvInfoList'; | 4 | +const url = 'http://apis.data.go.kr/1470000/FoodAdtvInfoService/getFoodAdtvInfoList?ServiceKey='; |
5 | -const queryParams = '?' + encodeURIComponent('ServiceKey') + '=ofY2ppOq5kBqT5jYPaGsW%2BEy7OR5a1bf5Z9PHvqNKvwO5DSCaU2x2qCj%2FoXnuB1YVbMTlErkHWSMEsR5b7isrw%3D%3D'; /* Service Key*/ | 5 | + |
6 | -queryParams += '&' + encodeURIComponent('prdlst_cd') + '=' + encodeURIComponent('C0118010300000'); /* */ | 6 | +//api key |
7 | -queryParams += '&' + encodeURIComponent('pc_kor_nm') + '=' + encodeURIComponent('과.채음료'); /* */ | 7 | +const key = 'ofY2ppOq5kBqT5jYPaGsW%2BEy7OR5a1bf5Z9PHvqNKvwO5DSCaU2x2qCj%2FoXnuB1YVbMTlErkHWSMEsR5b7isrw%3D%3D'; |
8 | -queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('1'); /* */ | 8 | + |
9 | -queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('3'); /* */ | 9 | +//REST(URL) |
10 | +const complete_url = url +key ;// '&numOfRows=2&pageNo=2'; | ||
11 | + | ||
12 | +console.log(complete_url); | ||
13 | + | ||
14 | +request(complete_url, function(error, response, body){ | ||
15 | + if(!error && response.statusCode ==200) | ||
16 | + console.log(body); | ||
17 | +}) | ||
18 | + | ||
19 | + | ||
20 | +/* | ||
21 | +queryParams += '&' + encodeURIComponent('prdlst_cd') + '=' + encodeURIComponent('C0118010300000'); | ||
22 | +queryParams += '&' + encodeURIComponent('pc_kor_nm') + '=' + encodeURIComponent('과.채음료'); | ||
23 | +queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('1'); | ||
24 | +queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('3'); | ||
25 | +*/ | ||
26 | + | ||
10 | 27 | ||
11 | /* | 28 | /* |
12 | 예제코드 | 29 | 예제코드 | ... | ... |
-
Please register or login to post a comment