forked from zhangshuai/douyin-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhot_search.go
85 lines (69 loc) · 3.19 KB
/
hot_search.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package douyinGo
import (
"context"
"github.com/zhangshuai/douyin-go/conf"
)
type HotSearchSentencesReq struct {
AccessToken string // 调用/oauth/client_token/生成的token,此token不需要用户授权。
}
type HotSearchSentence struct {
HotLevel int64 `json:"hot_level"` // 热度 综合点赞、评论、转发等计算得出
Sentence string `json:"sentence"` // 热点词
}
type HotSearchSentencesData struct {
ActiveTime string `json:"active_time"` // 刷新时间
List []HotSearchSentence `json:"list"` // 实时热点词
DYError
}
type HotSearchSentencesRes struct {
Data HotSearchSentencesData `json:"data"`
Extra DYExtra `json:"extra"`
}
// 获取实时热点词
func (m *Manager) HotSearchSentences(req HotSearchSentencesReq) (res HotSearchSentencesRes, err error) {
err = m.client.CallWithJson(context.Background(), &res, "GET", m.url("%s?access_token=%s", conf.API_HOT_SEARCH_SENTENCES, req.AccessToken), nil, nil)
return res, err
}
type HotSearchTrendingSentencesReq struct {
AccessToken string // 调用/oauth/client_token/生成的token,此token不需要用户授权。
Cursor int64 // 分页游标, 第一页请求cursor是0, response中会返回下一页请求用到的cursor, 同时response还会返回has_more来表明是否有更多的数据。
Count int64 // 每页数量
}
type HotSearchTrendingSentence struct {
HotLevel int64 `json:"hot_level"` // 热度 综合点赞、评论、转发等计算得出
Sentence string `json:"sentence"` // 热点词
Label int64 `json:"label"` // 标签: * `0` - 无 * `1` - 新 * `2` - 推荐 * `3` - 热 * `4` - 爆 * `5` - 首发
}
type HotSearchTrendingSentencesData struct {
List []HotSearchTrendingSentence `json:"list"` // 实时热点词
Total int32 `json:"total"` // 总数
Cursor int64 `json:"cursor"` // 用于下一页请求的cursor
HasMore bool `json:"has_more"` // 更多数据
DYError
}
type HotSearchTrendingSentencesRes struct {
Data HotSearchTrendingSentencesData `json:"data"`
Extra DYExtra `json:"extra"`
}
// 获取上升词
func (m *Manager) HotSearchTrendingSentences(req HotSearchTrendingSentencesReq) (res HotSearchTrendingSentencesRes, err error) {
err = m.client.CallWithJson(context.Background(), &res, "GET", m.url("%s?access_token=%s&cursor=%d&count=%d", conf.API_HOT_SEARCH_TRENDING_SENTENCES, req.AccessToken, req.Cursor, req.Count), nil, nil)
return res, err
}
type HotSearchVideosReq struct {
AccessToken string // 调用/oauth/client_token/生成的token,此token不需要用户授权。
HotSentence string // 热点词
}
type HotSearchVideosData struct {
List []Video `json:"list"`
DYError
}
type HotSearchVideosRes struct {
Data HotSearchVideosData `json:"data"`
Extra DYExtra `json:"extra"`
}
// 获取热点词聚合的视频
func (m *Manager) HotSearchVideos(req HotSearchVideosReq) (res HotSearchVideosRes, err error) {
err = m.client.CallWithJson(context.Background(), &res, "GET", m.url("%s?access_token=%s&hot_sentence=%s", conf.API_HOT_SEARCH_VIDEOS, req.AccessToken, req.HotSentence), nil, nil)
return res, err
}