diff options
Diffstat (limited to 'aplus.go')
| -rw-r--r-- | aplus.go | 50 |
1 files changed, 17 insertions, 33 deletions
| @@ -10,13 +10,25 @@ import ( | |||
| 10 | "strings" | 10 | "strings" |
| 11 | ) | 11 | ) |
| 12 | 12 | ||
| 13 | func launch_aplus(course_code int) { | ||
| 14 | aplus_link := fmt.Sprintf("%s/courses/%d/external_tools/sessionless_launch?id=913&access_token=%s", base_link, course_code, token) // 7329 always works | ||
| 15 | aplus := get_aplus(token, aplus_link, client) | ||
| 16 | |||
| 17 | resp, _ := client.Get(aplus) | ||
| 18 | body, _ := io.ReadAll(resp.Body) | ||
| 19 | |||
| 20 | form_str := get_form_from_request_body(body) | ||
| 21 | form_values := parse_form(form_str) | ||
| 22 | |||
| 23 | resp, _ = client.PostForm("https://floridapoly.aplusattendance.com/canvas", form_values) | ||
| 24 | body, _ = io.ReadAll(resp.Body) | ||
| 25 | |||
| 26 | fmt.Println(string(body)) | ||
| 27 | } | ||
| 28 | |||
| 13 | func get_aplus(token string, link string, client http.Client) string { | 29 | func get_aplus(token string, link string, client http.Client) string { |
| 14 | resp, err := client.Get(link) | 30 | resp, _ := client.Get(link) |
| 15 | 31 | ||
| 16 | if err != nil { | ||
| 17 | fmt.Println("Error performing GET request to initial link.") | ||
| 18 | } | ||
| 19 | defer resp.Body.Close() | ||
| 20 | body, _ := io.ReadAll(resp.Body) | 32 | body, _ := io.ReadAll(resp.Body) |
| 21 | 33 | ||
| 22 | var aplus Aplus | 34 | var aplus Aplus |
| @@ -75,31 +87,3 @@ func extract_attribute(input string, attribute string) string { | |||
| 75 | 87 | ||
| 76 | return input[start : start+end] | 88 | return input[start : start+end] |
| 77 | } | 89 | } |
| 78 | |||
| 79 | func launch_aplus(course_code int) { | ||
| 80 | aplus_link := fmt.Sprintf("%s/courses/%d/external_tools/sessionless_launch?id=913&access_token=%s", base_link, course_code, token) // 7329 always works | ||
| 81 | aplus := get_aplus(token, aplus_link, client) | ||
| 82 | |||
| 83 | resp, err := client.Get(aplus) | ||
| 84 | |||
| 85 | if err != nil { | ||
| 86 | fmt.Println("Error while performing GET request to aplus auth link.") | ||
| 87 | } | ||
| 88 | |||
| 89 | defer resp.Body.Close() | ||
| 90 | body, _ := io.ReadAll(resp.Body) | ||
| 91 | |||
| 92 | form_str := get_form_from_request_body(body) | ||
| 93 | |||
| 94 | form_values := parse_form(form_str) | ||
| 95 | |||
| 96 | resp, _ = client.PostForm("https://floridapoly.aplusattendance.com/canvas", form_values) | ||
| 97 | |||
| 98 | body, err = io.ReadAll(resp.Body) | ||
| 99 | |||
| 100 | if err != nil { | ||
| 101 | fmt.Println("Error reading body of post form response from aplus attendance.") | ||
| 102 | } | ||
| 103 | |||
| 104 | fmt.Println(string(body)) | ||
| 105 | } | ||
