-
Notifications
You must be signed in to change notification settings - Fork 0
API User
Terry Chan edited this page Nov 27, 2016
·
5 revisions
For user register.
- username
- password
# 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'){
"ret": 0,
"msg": "ok."
}{
"ret": 1,
"msg": "username has benn used."
}For user login.
- username
- password
# 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'){
"token": "1ae6b0279352be65bb1b41b1ebe85e20",
"user": {
"id": 16,
"username": "terry"
},
"ret": 0,
"msg": "ok"
}{
"ret": 2,
"msg": "username and password missmatch."
}TBD.
Update personal information.
TBD.