Skip to content

API User

Terry Chan edited this page Dec 9, 2016 · 5 revisions

/api/user/register

POST

For user register.

form url-encoded parameter

  • username
  • password

jQuery example

// 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() {
    /* ... */
});

return type

{
  "ret": 0,
  "msg": "ok."
}
{
  "ret": 1,
  "msg": "username has benn used."
}

/api/user/login

POST

For user login.

form url-encoded parameter

  • username
  • password
  • expiry_time(optional, in second)

jQuery example

// 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() {
    /* ... */
});

return type

{
  "ret": 0,
  "msg": "ok.",
  "user": {
    "id": 63,
    "username": "terryc",
    "token": "22b12a163b07c80c6991eb2c5ce76627"
  }
}
{
  "ret": 2,
  "msg": "username and password missmatch."
}

/api/user

GET

to be done

POST

Update personal information.

to be done

Clone this wiki locally