tonyzimbinski / infinite-campus Goto Github PK
View Code? Open in Web Editor NEW๐ unofficial API for Infinite Campus written in Node JS
License: GNU General Public License v3.0
๐ unofficial API for Infinite Campus written in Node JS
License: GNU General Public License v3.0
If the password or username has a symbol like ! or ? then it says theres a password error. You need to url encode the password in order to work.
Nice little lib. However, it's not best practice to transmit secure login credentials over http GET in the URL. Your username/password is exposed to anything listening to or logging URL traffic. Looks like a drop-in replacement to use the POST version of the same URL.
Example:
// _login() function around line 237
request.post(this.district.district_baseurl + 'verify.jsp?nonBrowser=true',
{
form: {
username,
password,
portalUrl: this.district.parent_login_url,
appName: this.district.district_app_name,
}
},
(err, res, body) => {
try {
errHandler.login.handle(err, res, body)
} catch (err) {
return this.emit('error', err)
}
resolve()
});
Cheers
My district uses a self hosted instance of Infinite Campus, is this project compatible with that?
How do you catch an error thrown when login information is incorrect? I do not want the program to exit when an incorrect login error is thrown.
not a big deal because (ironically) 2.0.1 was only pushed to fix a version mismatch between github & npm ๐คฆโโ๏ธ
Login should use POST and submit the username and password as part of the request body rather than in the query string. Using GET and query string params for logins will be blocked by the Infinite Campus application in the near future.
Some courses work fine, but others are undefined despite being no different to others. I used the example code from the github page.
the new "Student Campus" broke how the API worked before as well as the format for the xml.
This comes with some good news though, student campus uses API calls to generate data client-side as opposed to server-generated HTML. This means that we can take a look at the network requests and find relevant API calls. Not only that, but we can ditch the terrible, horrible, no good, very bad XML file.
Some courses don't have grades on campus, and this throws an error when getting courses.
I installed the "npm i infinite-campus" and I looked at the documentation and followed the all the code, but when I run the code it says this error:
/Users/Name/node_modules/reqjs-err-handler/index.js:131
throw new Error([${prefix}][${errPrefix}] ${text}
)
^
Error: [LOGIN][F_BODY_0] Username/Password is incorrect.
at ErrorHandler._throwErr (/Users/Name/node_modules/reqjs-err-handler/index.js:131:11)
at /Users/Name/node_modules/reqjs-err-handler/index.js:61:18
at Array.forEach ()
at ErrorHandler.handle (/Users/Name/node_modules/reqjs-err-handler/index.js:58:30)
at Request._callback (/Users/Name/node_modules/infinite-campus/index.js:207:26)
at Request.self.callback (/Users/Name/node_modules/request/request.js:185:22)
at Request.emit (events.js:315:20)
at Request. (/Users/Name/node_modules/request/request.js:1154:10)
at Request.emit (events.js:315:20)
at IncomingMessage. (/Users/Name/node_modules/request/request.js:1076:12)
This is my code:
const InfiniteCampus = require('infinite-campus')
const user = new InfiniteCampus('Atlanta', 'GA', 'ihamilto0684', 'XXXXX')
// wait until we are done logging in
user.on('ready', () => {
// now that we are logged in, fetch courses
user.getCourses().then((courses) => {
console.log(courses)
})
})
When I am trying to run the demo application I am getting the notifications back however, the link is not valid in the notification ( link: 'https://utcloud1.infinitecampus.org/campus/undefinedundefined',)
Not only that looks like there is an error on line 318 (index.js) that is causing problems) #
`const InfiniteCampus = require('infinite-campus')
// log in District Name State Username Password
const user = new InfiniteCampus('xxxxx', 'xx', 'xxxxxxxx', 'xxxxxxxx')
// wait until we are done logging in
user.on('ready', () => {
// now that we are logged in...
// get grades from all courses, returns an array of terms containing class information (see docs)
user.getCourses().then((terms) => {
console.log(terms)
// [{name:"Q1", courses: [{name: "1 English", grades:{}, ...}, ...]}, ... ]
})
// get the last 20 notifications
user.getNotifications(20).then((notifications) => {
console.log(notifications)
// [{id: "1111", test: "BOB recieved a new grade of A", timestamp: 1234, read: false, ... }, ...]
// then mark all notifications as read
user.markAllNotificationsRead().then(() => {
console.log('notifications marked as read...')
})
})
})
// listen for any errors thrown while logging in
user.on('error', (err) => {
console.log('Error while Logging in. Bad credentials.' + err)
})`
Firstly, I'm quite honestly amazed and thankful for this API. If it weren't for this API, I was going to have to make a web scraper, and that would've taken a while! So, thank you @qwazwsx!
Now for the issue I'm having:
I created a new NodeJS
project on Replit, and initialized a new instance of InfiniteCampus()
with the necessary information. The login was successful, and I was able to programmatically view my courses. Wonderful! However, the one most crucial part of my project, the grades
, returned undefined
. Here's my current script:
const InfiniteCampus = require('infinite-campus');
const DISTRICT = process.env['DISTRICT'];
const STATE = process.env['STATE'];
const IC_USER = process.env['IC_USER'];
const IC_PASS = process.env['IC_PASS'];
const user = new InfiniteCampus(DISTRICT, STATE, IC_USER, IC_PASS);
user.on('ready', () => {
console.log("Login successful!");
user.getCourses().then(terms => {
console.log(terms[0].courses[0].grades);
});
});
Is there any specific reason this isn't working? Maybe something on Infinite Campus changed?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.