diff --git a/aplus.go b/aplus.go index 3f3640b..18beddb 100644 --- a/aplus.go +++ b/aplus.go @@ -10,13 +10,25 @@ import ( "strings" ) -func get_aplus(token string, link string, client http.Client) string { - resp, err := client.Get(link) +func launch_aplus(course_code int) { + aplus_link := fmt.Sprintf("%s/courses/%d/external_tools/sessionless_launch?id=913&access_token=%s", base_link, course_code, token) // 7329 always works + aplus := get_aplus(token, aplus_link, client) + + resp, _ := client.Get(aplus) + body, _ := io.ReadAll(resp.Body) + + form_str := get_form_from_request_body(body) + form_values := parse_form(form_str) + + resp, _ = client.PostForm("https://floridapoly.aplusattendance.com/canvas", form_values) + body, _ = io.ReadAll(resp.Body) + + fmt.Println(string(body)) +} + +func get_aplus(token string, link string, client http.Client) string { + resp, _ := client.Get(link) - if err != nil { - fmt.Println("Error performing GET request to initial link.") - } - defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) var aplus Aplus @@ -75,31 +87,3 @@ func extract_attribute(input string, attribute string) string { return input[start : start+end] } - -func launch_aplus(course_code int) { - aplus_link := fmt.Sprintf("%s/courses/%d/external_tools/sessionless_launch?id=913&access_token=%s", base_link, course_code, token) // 7329 always works - aplus := get_aplus(token, aplus_link, client) - - resp, err := client.Get(aplus) - - if err != nil { - fmt.Println("Error while performing GET request to aplus auth link.") - } - - defer resp.Body.Close() - body, _ := io.ReadAll(resp.Body) - - form_str := get_form_from_request_body(body) - - form_values := parse_form(form_str) - - resp, _ = client.PostForm("https://floridapoly.aplusattendance.com/canvas", form_values) - - body, err = io.ReadAll(resp.Body) - - if err != nil { - fmt.Println("Error reading body of post form response from aplus attendance.") - } - - fmt.Println(string(body)) -}