mirror of
https://codeberg.org/flpolyaplus/aplus.git
synced 2024-11-21 17:00:30 -05:00
further simplify launch_aplus function and get_aplus function
This commit is contained in:
parent
e46ca43d4c
commit
a8b1886d86
50
aplus.go
50
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)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("Error performing GET request to initial link.")
|
||||
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))
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
func get_aplus(token string, link string, client http.Client) string {
|
||||
resp, _ := client.Get(link)
|
||||
|
||||
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))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user