调用示例
调用示例
第一步:获取token
接口地址:http://openapi.douyu.com/api/thirdPart/token
请求方式:get
是否需要鉴权:是
get 请求参数:
| 参数名称 | 是否可选 | 类型 | 描述 |
|---|---|---|---|
| aid | 必填 | string | 身份标识 |
| auth | 必填 | string | 签名信息 |
| time | 必填 | int | 时间戳 |
CURL 请求示例:
curl -X GET 'http://openapi.douyu.com/api/thirdPart/token?aid=justdo&time=1521552628&auth=0b0bc5914e6f0081ae7895195766c5eb' -H 'content-type: application/json'
返回成功时:data里为token,2小时有效期
| 字段名 | 字段解释 | 字段类型 | 字段值样例 |
|---|---|---|---|
| token | token凭证 | string | 3671c7c16a4342f3fe610cc83147238c |
| expire | 过期时间 | int | 7200 |
auth获取规则:
请求uri加上get请求参数从a-z升序排列,然后拼接,最后加上aid的秘钥,post请求参数不参与加密。
eg:
auth = md5(/api/thirdPart/token?aid=ttlive&time=1521791007VFCS4u6e6kpev7uO!t)
说明:
"1521791007" :时间戳
"VFCS4u6e6kpev7uO!t" : 开发者秘钥
第二步:调用接口
示例
接口地址:http://openapi.douyu.com/api/thirdPart/getRoomInfo
请求方式:post
是否需要鉴权:是
get 请求参数:
| 参数名称 | 是否可选 | 类型 | 描述 |
|---|---|---|---|
| aid | 必填 | string | 身份标识 |
| auth | 必填 | string | 签名信息 |
| time | 必填 | int | 时间戳 |
| token | 必填 | string | 接口权限验证token |
post 请求参数:
| 参数名称 | 是否可选 | 类型 | 描述 |
|---|---|---|---|
| rid | 必填 | int | 房间ID |
| cid_type | 可选 | int | 分类类型,1:一级分类,2:二级分类,3:三级分类 |
| cid | 可选 | int | 分类ID |
CURL 请求示例:
curl -X POST 'http://openapi.douyu.com/api/thirdPart/getRoomInfo?aid=justdo&time=1521182982&auth=297f6227b2986cc37b217f78fb59eb05&token=3671c7c16a4342f3fe610cc83147238c' -H 'content-type: application/json' -d '{"cid_type":1,"cid":2111,"rid":688}'
auth获取规则:
请求uri加上get请求参数从a-z升序排列,然后拼接,最后加上aid的秘钥,post请求参数不参与加密。
eg:
auth = md5(/api/thirdPart/getRoomInfo?aid=ttlive&time=1521791007&token=3671c7c16a4342f3fe610cc83147238cVFCS4u6e6kpev7uO!t)
说明:
"3671c7c16a4342f3fe610cc83147238c" :/api/thirdPart/thirdPart/token接口返回token,两个小时有效期
"VFCS4u6e6kpev7uO!t" : 开发者秘钥