diff --git a/main.go b/main.go index a33e192..eb88b8d 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "net/http" + "strings" ) func get_courses(token string, link string, client http.Client) []CanvasCourse { @@ -58,21 +59,22 @@ func main() { // https://canvas.instructure.com/api/v1/courses?access_token={}&per_page=100", canvas_token base_link := "https://floridapolytechnic.instructure.com/api/v1" - token := "insert api key here" + token := "token here" + + // course selection by user happens below //favorites := fmt.Sprintf("%s/users/self/favorites/courses?access_token=%s&per_page=100", base_link, token) //all_courses := fmt.Sprintf("%s/courses?access_token=%s&per_page=100", base_link,token) - //var canvas_courses []CanvasCourse //canvas_courses = get_courses(token, favorites, client) //var course_ids []uint64 //course_ids = get_course_ids(canvas_courses) - //selected := 1 // course_ids[selected] + // course selection by user happens above + aplus_link := fmt.Sprintf("%s/courses/%d/external_tools/sessionless_launch?id=913&access_token=%s", base_link, 7329, token) // 7329 always works var aplus string aplus = get_aplus(token, aplus_link, client) fmt.Println(aplus) - resp, err := client.Get(aplus) if err != nil { @@ -82,9 +84,104 @@ func main() { //fmt.Println(resp) defer resp.Body.Close() - //body, err := io.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) //fmt.Println(string(body)) //fmt.Println(resp) + //fmt.Println("Status code:", resp.StatusCode) + + if err != nil { + // handle error + } + + body_str := string(body) + + form_start := strings.Index(body_str, "