-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclassesinterface.html
85 lines (64 loc) · 4.58 KB
/
classesinterface.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<html>
<head>
<style>
body
{
white-space: pre;
font-size: 12px;
}
</style>
<script src="https://classes.colorado.edu/sam/core.js?1555043683032"></script>
<body>
IF YOU TRUST <a href="https://github.com/Rob--W/cors-anywhere">https://github.com/Rob--W/cors-anywhere</a> AND THIS SITE,
YOU MAY PROVIDE YOUR OAUTH TOKEN FROM THE RESULTING URL OF VISITING
<a href="https://ping.prod.cu.edu/as/authorization.oauth2?client_id=CUBoulderClassSearch&response_type=token&IdpSelectorId=BoulderIDP&scope=AcademicRecords&redirect_uri=https://classes.colorado.edu/sam/oauth.html">https://ping.prod.cu.edu/as/authorization.oauth2
?client_id=CUBoulderClassSearch
&response_type=token
&IdpSelectorId=BoulderIDP
&scope=AcademicRecords
&redirect_uri=https://classes.colorado.edu/sam/oauth.html</a>
AND I WILL BE ABLE TO USE THE TOKEN TO QUERY YOUR COURSE HISTORY
TO ENHANCE THE PRESENTATION OF THE PREREQUISITE GRAPH.
THE TOKENS SHOULD BE VALID FOR 2 HOURS (ENSURE EXPIRES_IN IS 7199 SECONDS)
AND WILL ONLY PROVIDE ACCESS TO ACADEMIC RECORDS (ENSURE &scope=AcademicRecords IS IN YOUR TOKEN REQUEST URL).
PLEASE ENSURE SURE YOU TRUST THESE SERVICES AND BE AWARE THAT IF YOU GIVE SOMEONE A LINK
THAT INCLUDES YOUR TEMPORARY TOKEN THEY WILL BE ABLE TO ACCESS YOUR ACADEMIC RECORDS FOR THE PERIOD OF ITS VALIDITY.
THIS IS HOW YOUR TOKEN WILL BE USED ON THIS SITE (A GET REQUEST TO THE CLASSES.COLORADO.EDU API):
[<a href="https://cors-anywhere.herokuapp.com/">https://cors-anywhere.herokuapp.com/</a> +] <a href="https://classes.colorado.edu/api/?page=sisproxy&oauth_token=8ZuiuPxrjWRkX3v5BVy6QBIzPOyQ">https://classes.colorado.edu/api/?page=sisproxy&oauth_token=8ZuiuPxrjWRkX3v5BVy6QBIzPOyQ</a>
<script>
function httpPostAsync(theUrl, callback, postContent) // thanks https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/send#Example_POST
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callback(xmlHttp.responseText);
}
xmlHttp.open("POST", theUrl, true); // true for asynchronous
xmlHttp.send( postContent );
}
function httpGetAsync(theUrl, callback) // thanks https://stackoverflow.com/a/4033310
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callback(xmlHttp.responseText);
}
xmlHttp.open("GET", theUrl, true); // true for asynchronous
xmlHttp.send(null);
}
// first query demonstrating using an oauth token for authorization
httpGetAsync( "https://cors-anywhere.herokuapp.com/https://classes.colorado.edu/api/?page=sisproxy&oauth_token=K1y7CHNAe16ZzK9XkEliJfAluEsf", data =>
{
document.body.innerHTML += "\n--- RESULT OF QUERYING CLASSES.COLORADO.EDU API FOR ACADEMIC RECORDS (REQUIRES OAUTH TOKEN) ---\n" + JSON.stringify( JSON.parse( data.substring( 10, data.length - 3 ) ), null, 2 );
// only do second fast query that doesn't require authorization after the slow one that requires authorization is complete
httpPostAsync( "https://cors-anywhere.herokuapp.com/https://classes.colorado.edu/api/?page=fose&route=search&keyword=larremore", data =>
{
document.body.innerHTML += "\n\n\n--- RESULT OF QUERYING CLASSES.COLORADO.EDU API FOR SEARCH QUERY (DOESN'T REQUIRE ANY OAUTH TOKEN)\n" + JSON.stringify( JSON.parse( data ), null, 2 );
},
`{"other":{"srcdb":"2197"},"criteria":[{"field":"keyword","value":"larremore"}]}` );
// https://www.url-encode-decode.com/ useful for figuring out how to construct the post payload
} )
// todo directly query view-source:https://classes.colorado.edu/ to find all query options
// fetch("https://datc.prod.cu.edu/selfservice-cubld/audit/create.html", {"headers":{"accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3","accept-language":"en-US,en;q=0.9","cache-control":"max-age=0","content-type":"application/x-www-form-urlencoded","upgrade-insecure-requests":"1"},"referrer":"https://datc.prod.cu.edu/selfservice-cubld/audit/create.html","referrerPolicy":"no-referrer-when-downgrade","body":"instcd=+++&previousDegreeProgramCollege=null°reeProgramCollege=&previousDegreeProgramDegree=null°reeProgramDegree=&previousWhatIfDegreeProgram=&whatIfDegreeProgram=&catalogYearTerm=&requiredMarker=&includeInProgressCourses=true&includeInProgressCourses=&includePlannedCourses=+&sysIn.evalsw=S&reportType=htm&useDefaultDegreePrograms=true&pageRefresh=false","method":"POST","mode":"cors"});
// i can't figure out how to grab from mycuhub but apexremote is what returns the actual information
</script>