Make BUAA Great Again
- SSO Login:
login
built inContext
- BUAA WiFi:
wifi
- Login
- Logout
- User Center:
user
- login
- get state
- Spoc:
spoc
- login
- query class table
- Course selection
- Boya Course:
boya
- login
- query
- select
- drop
- A universal request API for extensions
- Smart Classroom:
class
- login
- checkin
- query
APIs not listed above might have been overlooked or deemed unimportant by me, but if you need them, feel free to open an issue or submit a pull request.
The basic process is:
- Initialize the
Context
- Set cccount
- (Optional) Specifies the file used to read and write cookies
- Login to context
- Get a subdomain instance
- Login to subdomain
- Call API in subdomain
There is a simple example:
use buaa::Context;
#[tokio::main]
async fn main() {
// Initialize the `Context`
let context = Context::new();
// Set account
context.set_account("username", "password")
// Specifies the file used to read and write cookies
context.with_cookies("cookie.json");
// Login to context
context.login().await.unwrap();
// Get a subdomain instance
let user = context.user();
// Login to subdomain
user.login().await.unwrap();
// Call API in subdomain
let state = user.get_state().await.unwrap();
println!("{}", state);
// (Optional) Save cookies to file
context.save();
}
A more complex example:
use buaa::Context;
#[tokio::main]
async fn main() {
let context = Context::new();
context.set_account("username", "password")
context.with_cookies("cookie.json");
context.login().await.unwrap();
let boya = context.boya();
boya.login().await.unwrap();
let course_list = boya.query_course().await.unwrap();
println!("{}", course_list);
let id = 1; // Get from course_list
let res = boya.select_course(6637).await.unwrap();
println!("{}", res);
context.save();
}
BUAA WiFi is independent of other APIs and does not require cookies or context.login
, so you need to provide a separate username and password:
use buaa::Context;
#[tokio::main]
async fn main() {
let context = Context::new();
context.set_account("username", "password")
let wifi = context.wifi();
// Login to BUAA WiFi
wifi.login().await.unwrap();
// Logout to BUAA WiFi
wifi.logout().await.unwrap();
}