mirror of
https://codeberg.org/flpolyaplus/aplus.git
synced 2024-11-22 01:10:29 -05:00
further simplify launch_aplus function and get_aplus function
This commit is contained in:
parent
e46ca43d4c
commit
a8b1886d86
52
aplus.go
52
aplus.go
@ -10,13 +10,25 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func get_aplus(token string, link string, client http.Client) string {
|
func launch_aplus(course_code int) {
|
||||||
resp, err := client.Get(link)
|
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)
|
body, _ := io.ReadAll(resp.Body)
|
||||||
|
|
||||||
var aplus Aplus
|
var aplus Aplus
|
||||||
@ -75,31 +87,3 @@ func extract_attribute(input string, attribute string) string {
|
|||||||
|
|
||||||
return input[start : start+end]
|
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))
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user