-
Notifications
You must be signed in to change notification settings - Fork 3
/
smart_cate_list.go
57 lines (49 loc) · 1.36 KB
/
smart_cate_list.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package douyuapi
import (
"github.com/birjemin/douyuapi/utils"
)
const smartCateListURI = "/api/thirdPart/smartCateList"
// SmartCateList ...
type SmartCateList struct {
BaseClient
Token string
}
// SmartCateListResponse ...
type SmartCateListResponse struct {
ErrorResponse
Data []struct {
Tag1ID int `json:"tag1_id"`
Tag1Name string `json:"tag1_name"`
Tag1Icon string `json:"tag1_icon"`
Tag2ID int `json:"tag2_id"`
Tag2Name string `json:"tag2_name"`
Tag2Icon string `json:"tag2_icon"`
RoomCount int `json:"room_count"`
} `json:"data"`
}
// Handle ...
func (p *SmartCateList) Handle(postJSON, timestamp string) (*SmartCateListResponse, error) {
return p.do(DouYuDomain+smartCateListURI, postJSON, timestamp)
}
// do
func (p *SmartCateList) do(url, postJSON, timestamp string) (*SmartCateListResponse, error) {
var params = map[string]string{
"aid": p.AID,
"time": timestamp,
"token": p.Token,
}
params["auth"] = GetSign(p.Secret, smartCateListURI, params)
url += "?" + utils.HTTPQueryBuild(params)
if err := p.Client.HTTPPostJSON(url, postJSON); err != nil {
return nil, err
}
var ret, errResp = new(SmartCateListResponse), new(ErrorResponse)
if err := p.Client.GetResponseJSON(ret, errResp); err != nil {
return nil, err
}
if errResp.Code != 0 {
ret.Code = errResp.Code
ret.Msg = errResp.Msg
}
return ret, nil
}