Skip to content

API User

Terry Chan edited this page Nov 27, 2016 · 5 revisions

/api/user/register

POST

For user register.

form url-encoded parameter

  • username
  • password

Python example

# Install the Python Requests library:
# `pip install requests`

import requests


def send_request():
    # Register
    # POST http://api.sysu.space/api/user/register

    try:
        response = requests.post(
            url="http://api.sysu.space/api/user/register",
            headers={
                "Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
            },
            data={
                "username": "terryc123321514",
                "password": "miaomiaomiao",
            },
        )
        print('Response HTTP Status Code: {status_code}'.format(
            status_code=response.status_code))
        print('Response HTTP Response Body: {content}'.format(
            content=response.content))
    except requests.exceptions.RequestException:
        print('HTTP Request failed')

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

Python example

# Install the Python Requests library:
# `pip install requests`

import requests


def send_request():
    # Login
    # POST http://api.sysu.space/api/user/login

    try:
        response = requests.post(
            url="http://api.sysu.space/api/user/login",
            headers={
                "Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
            },
            data={
                "username": "terry",
                "password": "miaomiaomiao",
            },
        )
        print('Response HTTP Status Code: {status_code}'.format(
            status_code=response.status_code))
        print('Response HTTP Response Body: {content}'.format(
            content=response.content))
    except requests.exceptions.RequestException:
        print('HTTP Request failed')

return type

{
  "token": "1ae6b0279352be65bb1b41b1ebe85e20",
  "user": {
    "id": 16,
    "username": "terry"
  },
  "ret": 0,
  "msg": "ok"
}
{
  "ret": 2,
  "msg": "username and password missmatch."
}

/api/user

GET

TBD.

POST

Update personal information.

TBD.

Clone this wiki locally