박찬수

soccer commit

No preview for this file type
...@@ -9,6 +9,8 @@ const HTTPS = require('https'); ...@@ -9,6 +9,8 @@ const HTTPS = require('https');
9 const domain = "2018102191.osschatbot2022.tk" 9 const domain = "2018102191.osschatbot2022.tk"
10 const sslport = 23023; 10 const sslport = 23023;
11 11
12 +var soccer = require('./soccer.js');
13 +
12 const bodyParser = require('body-parser'); 14 const bodyParser = require('body-parser');
13 var app = express(); 15 var app = express();
14 app.use(bodyParser.json()); 16 app.use(bodyParser.json());
...@@ -26,6 +28,8 @@ app.post('/hook', function (req, res) { ...@@ -26,6 +28,8 @@ app.post('/hook', function (req, res) {
26 console.log('[request message]', eventObj.message); 28 console.log('[request message]', eventObj.message);
27 console.log("Receive Message : ", eventObj.message.text); 29 console.log("Receive Message : ", eventObj.message.text);
28 30
31 + console.log(soccer.GetPlayerInfo(276, 2019));
32 +
29 request.post( 33 request.post(
30 { 34 {
31 url: TARGET_URL, 35 url: TARGET_URL,
......
1 -var request = require('request'); 1 +module.exports = {
2 - 2 + GetPlayerInfo : function(playerID, season){
3 -var options = { 3 + var request = require('request');
4 + var options = {
4 method: 'GET', 5 method: 'GET',
5 url: 'https://v3.football.api-sports.io/players', 6 url: 'https://v3.football.api-sports.io/players',
6 - qs: {id: '276', season: '2019'}, 7 + qs: {id: playerID, season: season},
7 headers: { 8 headers: {
8 'x-rapidapi-host': 'v3.football.api-sports.io', 9 'x-rapidapi-host': 'v3.football.api-sports.io',
9 - 'x-rapidapi-key' : '526fc70a2e8b315e9a960ac4b4764191' 10 + 'x-rapidapi-key': '526fc70a2e8b315e9a960ac4b4764191'
10 } 11 }
11 -}; 12 + };
12 - 13 + request(options, function (error, response) {
13 -request(options, function (error, response) {
14 if (error) throw new Error(error); 14 if (error) throw new Error(error);
15 console.log(response.body); 15 console.log(response.body);
16 -});
...\ No newline at end of file ...\ No newline at end of file
16 + });
17 + }
18 +}
......