summaryrefslogtreecommitdiff
path: root/aplus.go
diff options
context:
space:
mode:
authorJuan Roig <jaroig@outlook.com>2023-11-13 02:56:01 -0500
committerJuan Roig <jaroig@outlook.com>2023-11-13 02:56:01 -0500
commita8b1886d86cfbbbf256b29387457db031be1e61a (patch)
tree3e646a6ff84020dc06f4280677bb68c1e79fb0f0 /aplus.go
parente46ca43d4cd6e44972123856bbe047eb0517768e (diff)
further simplify launch_aplus function and get_aplus function
Diffstat (limited to 'aplus.go')
-rw-r--r--aplus.go50
1 files changed, 17 insertions, 33 deletions
diff --git a/aplus.go b/aplus.go
index 3f3640b..18beddb 100644
--- a/aplus.go
+++ b/aplus.go
@@ -10,13 +10,25 @@ import (
10 "strings" 10 "strings"
11) 11)
12 12
13func 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
13func get_aplus(token string, link string, client http.Client) string { 29func 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
79func 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}