-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathlikes.go
54 lines (46 loc) · 1.21 KB
/
likes.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
package vkapi
import (
"encoding/json"
"net/url"
"strconv"
)
const (
TypePost = "post"
TypeComment = "comment"
TypePhoto = "photo"
TypeDocument = "doc"
TypeAudio = "audio"
TypeVideo = "video"
TypeNote = "note"
TypePhotoComment = "photo_comment"
TypeVideoComment = "video_comment"
TypeTopicComment = "topic_comment"
TypeSitepage = "sitepage"
)
type Likes struct {
Count int `json:"count"`
Users []*LikeUser `json:"items"`
}
type LikeUser struct {
Type string `json:"profile"`
ID int `json:"id"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
}
func (client *VKClient) LikesGet(itemType string, ownerID int, itemID int, count int, params url.Values) (int, []*LikeUser, error) {
if params == nil {
params = url.Values{}
}
params.Add("type", itemType)
params.Add("count", strconv.Itoa(count))
params.Add("owner_id", strconv.Itoa(ownerID))
params.Add("item_id", strconv.Itoa(itemID))
params.Add("extended", "1")
resp, err := client.MakeRequest("likes.getList", params)
if err != nil {
return 0, nil, err
}
var likes Likes
json.Unmarshal(resp.Response, &likes)
return likes.Count, likes.Users, nil
}