首页 > 远端RESTful API调用

远端RESTful API调用

GET /api/accounts HTTP/1.1
Content-Type: application/json
X-Access-Token: username:token

这种 API,Python 要怎么调用啊??
POST 登录生成 token 以后要怎么调用啊??? 求告知


把获得的token保存在本地,每次请求的时候带上token就好了


import requests

r = requests.get(url)


import requests
r = requests.get(url, cookies=cookies)


import requests
token = '从你存储的地方取值'
headers = {
    'Content-Type': 'application/json',
    'X-Access-Token': 'username:{0}'.format(token)
}

r = request.get('/api/accounts', headers=headers)
print r.text
【热门文章】
【热门文章】