Skip to content

Commit

Permalink
Fave.getPhotos
Browse files Browse the repository at this point in the history
  • Loading branch information
Vorkytaka committed Apr 19, 2017
1 parent 68b8224 commit f811a47
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ if err != nil {
* [GetInfo](https://vk.com/dev/account.getInfo)
* [GetProfileInfo](https://vk.com/dev/account.getProfileInfo)
* [Fave](https://vk.com/dev/fave)
* [GetUsers](https://vk.com/dev/fave.getUsers)
* [GetLinks](https://vk.com/dev/fave.getLinks)
* [GetPhotos](https://vk.com/dev/fave.getPhotos)
* [GetUsers](https://vk.com/dev/fave.getUsers)
* [Photos](https://vk.com/dev/photos)
* [GetWallUploadServer](https://vk.com/dev/photos.getWallUploadServer)
* [SaveWallPhoto](https://vk.com/dev/photos.photos.saveWallPhoto)
Expand Down
21 changes: 21 additions & 0 deletions easyvk/fave-response.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,25 @@ type FaveLinks []struct {
ImageSrc string `json:"image_src"`
ImageMiddle string `json:"image_middle"`
ImageBig string `json:"image_big"`
}

// A FavePhotos describes a slice of photos
// that the current user has bookmarked.
type FavePhotos []struct {
AccessKey string `json:"access_key"`
Aid int `json:"aid"`
Created int `json:"created"`
Height int `json:"height"`
OwnerID int `json:"owner_id"`
Pid int `json:"pid"`
PostID int `json:"post_id,omitempty"`
Src string `json:"src"`
SrcBig string `json:"src_big"`
SrcSmall string `json:"src_small"`
SrcXbig string `json:"src_xbig"`
SrcXxbig string `json:"src_xxbig"`
SrcXxxbig string `json:"src_xxxbig,omitempty"`
Text string `json:"text"`
UserID int `json:"user_id"`
Width int `json:"width"`
}
22 changes: 22 additions & 0 deletions easyvk/fave.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,25 @@ func (f *Fave) GetLinks(offset, count uint) (FaveLinks, uint, error) {

return links, quantity, nil
}

// GetPhotos returns a list of photos that the current user has bookmarked.
// Also this func return count of all bookmarked photos.
func (f *Fave) GetPhotos(offset, count uint) (FavePhotos, uint, error) {
params := map[string]string{
"offset": fmt.Sprint(offset),
"count": fmt.Sprint(count),
"photo_sizes": "0",
}
resp, err := f.vk.Request("fave.getPhotos", params)
if err != nil {
return FavePhotos{}, 0, err
}
nextResp, quantity, err := f.vk.ResponseWithCount(resp)
var links FavePhotos
err = json.Unmarshal(nextResp, &links)
if err != nil {
return FavePhotos{}, 0, err
}

return links, quantity, nil
}

0 comments on commit f811a47

Please sign in to comment.