commit a8b1886d86cfbbbf256b29387457db031be1e61a
parent e46ca43d4cd6e44972123856bbe047eb0517768e
Author: Juan Roig <jaroig@outlook.com>
Date: Mon, 13 Nov 2023 02:56:01 -0500
further simplify launch_aplus function and get_aplus function
Diffstat:
| M | aplus.go | | | 50 | +++++++++++++++++--------------------------------- |
1 file changed, 17 insertions(+), 33 deletions(-)
diff --git a/aplus.go b/aplus.go
@@ -10,13 +10,25 @@ import (
"strings"
)
+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, err := client.Get(link)
+ 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))
-}