-
Notifications
You must be signed in to change notification settings - Fork 0
API User
Terry Chan edited this page Dec 9, 2016
·
5 revisions
For user register.
- username
- password
// Register (POST http://api.sysu.space/api/user/register)
jQuery.ajax({
url: "http://api.sysu.space/api/user/register",
type: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
},
contentType: "application/x-www-form-urlencoded",
data: {
"username": "terryc123321514",
"password": "miaomiaomiao",
},
})
.done(function(data, textStatus, jqXHR) {
console.log("HTTP Request Succeeded: " + jqXHR.status);
console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
console.log("HTTP Request Failed");
})
.always(function() {
/* ... */
});{
"ret": 0,
"msg": "ok."
}{
"ret": 1,
"msg": "username has benn used."
}For user login.
- username
- password
- expiry_time(optional, in second)
// Login (POST http://api.sysu.space/api/user/login)
jQuery.ajax({
url: "http://api.sysu.space/api/user/login",
type: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
},
contentType: "application/x-www-form-urlencoded",
data: {
"username": "terry",
"password": "miaomiaomiao",
},
})
.done(function(data, textStatus, jqXHR) {
console.log("HTTP Request Succeeded: " + jqXHR.status);
console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
console.log("HTTP Request Failed");
})
.always(function() {
/* ... */
});{
"ret": 0,
"msg": "ok.",
"user": {
"id": 63,
"username": "terryc",
"token": "22b12a163b07c80c6991eb2c5ce76627"
}
}{
"ret": 2,
"msg": "username and password missmatch."
}to be done
Update personal information.
to be done