-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcomment.go
73 lines (64 loc) · 2.41 KB
/
comment.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
package ncmapi
import (
"fmt"
"net/http"
apitypes "github.com/benmooo/ncmapi/api-types"
)
// 说明 : 调用此接口,可发送评论或者删除评论
//
// New Comment
// required
// t:1 发送, 2 回复
// type: 数字,资源类型,对应歌曲,mv,专辑,歌单,电台,视频对应以下类型
// id:对应资源 id
// content :要发送的内容
// commentId :回复的评论id (回复评论时必填)
//
// Delete Comment
// required
// t:0 删除
// type: 数字,资源类型,对应歌曲,mv,专辑,歌单,电台,视频对应以下类型
// id:对应资源 id
// content :内容 id,可通过 /comment/mv 等接口获取
func (api *NeteaseAPI) Comment(t int, commentType apitypes.ResourceTypeCode, id int, opts ...apitypes.H) (*APIResponse, error) {
// data := concatPayload(apitypes.H{"t": t, "type": commentType, "id": id}, opts...)
// option := apitypes.DefaultRequestOption().AddCookie("os", "pc")
// data := hm{}
// resp, err := api.Req(http.MethodPost, APIRoutes["comment"], data, nil)
// return resp, err
return nil, nil
}
// required
// rid: resource id
// rt: resource type
// cmt: comment body
func (api *NeteaseAPI) CommentCreate(rid int, rt apitypes.ResourceTypeCode, cmt string) (*APIResponse, error) {
opt := apitypes.DefaultRequestOption().AddCookie("os", "pc")
data := hm{"threadId": fmt.Sprintf("%s%d", rt, rid), "content": cmt}
u := replaceAllRouteParams(APIRoutes["comment"], "add")
resp, err := api.Req(http.MethodPost, u, data, opt)
return resp, err
}
// required
// rid: resource id
// rt: resource type
// reid: the comment id of reply to
// cmt: comment body
func (api *NeteaseAPI) CommentRe(rid int, rt apitypes.ResourceTypeCode, reid int, cmt string) (*APIResponse, error) {
opt := apitypes.DefaultRequestOption().AddCookie("os", "pc")
data := hm{"threadId": fmt.Sprintf("%s%d", rt, rid), "content": cmt, "commentId": reid}
u := replaceAllRouteParams(APIRoutes["comment"], "reply")
resp, err := api.Req(http.MethodPost, u, data, opt)
return resp, err
}
// required
// rid: resource id
// rt: resource type
// cmtid: comment id
func (api *NeteaseAPI) CommentDel(rid int, rt apitypes.ResourceTypeCode, cmtid int) (*APIResponse, error) {
opt := apitypes.DefaultRequestOption().AddCookie("os", "pc")
data := hm{"threadId": fmt.Sprintf("%s%d", rt, rid), "commentId": cmtid}
u := replaceAllRouteParams(APIRoutes["comment"], "delete")
resp, err := api.Req(http.MethodPost, u, data, opt)
return resp, err
}