Skip to content
Snippets Groups Projects
Unverified Commit f2f2fe26 authored by Recolic Keghart's avatar Recolic Keghart
Browse files

IMPORTANT BUG FIX: TEACHERMATE API UPDATE

parent 0843f0b0
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
https://tm.recolic.net/ https://tm.recolic.net/
## WARNING
**Update At 2019-04-23: 自动签到API发生了修改,请务必更新你的脚本,否则你可能失去生命。**
## Hard PreRequirements ## Hard PreRequirements
Non-Windows OS. curl. bash. fish. awk. grep. One mp3 player available on command line. Non-Windows OS. curl. bash. fish. awk. grep. One mp3 player available on command line.
......
...@@ -41,11 +41,18 @@ function do_signin ...@@ -41,11 +41,18 @@ function do_signin
end end
echo "sleep for $_autosign_delay seconds..." echo "sleep for $_autosign_delay seconds..."
sleep $_autosign_delay sleep $_autosign_delay
set _courseid (curl "$_url" -v 2>&1 | grep '^< Location: ' | sed 's/^.*course_id=//') # set _courseid (curl "$_url" -v 2>&1 | grep '^< Location: ' | sed 's/^.*course_id=//')
set _wx_csrf (grep 'Set-Cookie' $cookiefl | sed 's/^.*wx_csrf_cookie=//' | sed 's/;.*$//') set _courseid (cat "$tmpfl" | grep 'id="course-id' | sed 's/^.*value="//g' | sed 's/" .*$//g')
curl "https://www.teachermate.com.cn/wechat-api/v1/class-attendance/student-sign-in" --data "openid=$_openid&course_id=$_courseid&lon=$_EastLongitude&lat=$_NorthLatitude&wx_csrf_name=$_wx_csrf" > $cookiefl set _signid (cat "$tmpfl" | grep 'id="sign-id' | sed 's/^.*value="//g' | sed 's/" .*$//g')
# set _wx_csrf (grep 'Set-Cookie' $cookiefl | sed 's/^.*wx_csrf_cookie=//' | sed 's/;.*$//')
set _wx_csrf (cat "$tmpfl" | grep 'id="token-hash' | sed 's/^.*value="//g' | sed 's/" .*$//g')
# recolic: they changed `www.teachermate.com.cn` to `v18.teachermate.com.cn` but doesn't provide new certificate... I added -k here. (which indicates that their client (wechat and dingtalk) doesn't check certificate at all)
curl -k "https://v18.teachermate.com.cn/wechat-api/v1/class-attendance/student-sign-in" --data "openid=$_openid&courseId=$_courseid&lon=$_EastLongitude&lat=$_NorthLatitude&signId=$_signid&wx_csrf_name=$_wx_csrf" > $cookiefl
grep -F 'repeat sign in' $cookiefl; and set signed_in true; and return grep -F 'repeat sign in' $cookiefl; and set signed_in true; and return
grep -F '":["OK",' $cookiefl; and set signed_in true; and on_signin_success; or on_signin_fail grep -F 'signRank' $cookiefl; and set signed_in true; and on_signin_success; and return
# Fail
cat $cookiefl
on_signin_fail
end end
while true while true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment