Last active
May 31, 2021 10:01
-
-
Save DearTanakorn/c5b6e47e36aba729b8a2357714fda430 to your computer and use it in GitHub Desktop.
Dschool auto checkin at 8am with line notification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cron = require('node-cron'); | |
var axios = require('axios'); | |
var user_id = "" | |
var school_id = "" | |
var line_token = "" | |
console.log("Schedule has been started"); | |
cron.schedule('0 8 * * 1-5', function(){ | |
axios.get( | |
`http://43.229.78.174/dschool_app_v2020/index.php?app=s&user_id=${user_id}&type=a&school_id=${school_id}&change_stat=1` | |
).then(res => { | |
axios.get( | |
`http://43.229.78.174/dschoolapp_service/read_qrcode.php?app=s&user_id=${user_id}&school_id=${school_id}&change_stat=1&type=a&qr=DSCHOOL-1111&card_stat=1`,{ | |
headers: { | |
Cookie: res.headers['set-cookie'] | |
}} | |
).then(resp => { | |
if (line_token) { | |
axios({ | |
method: "post", | |
url: "https://notify-api.line.me/api/notify", | |
headers: { | |
"Content-Type": "application/x-www-form-urlencoded", | |
"Authorization": `Bearer ${line_token}`, | |
}, | |
data: 'message=ลงชื่อสำเร็จแล้ว' | |
}).catch((err) => { | |
if (err.response.data) return console.log(err.response.data.message); | |
return console.log(err); | |
}); | |
} else { | |
return console.log(resp.status); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment