-
Notifications
You must be signed in to change notification settings - Fork 1
/
feed.go
64 lines (54 loc) · 1.06 KB
/
feed.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
package flickr
import "fmt"
type FeedPhoto struct {
Id string
Title string
Owner string
OwnerName string
Secret string
Server string
Farm int
}
type FeedRaw struct {
Photos struct {
Photo []struct {
Id string
Secret string
Server string
Farm int
Owner string
Username string
Title string
IsPublic int
IsFriend int
IsFamily int
}
}
}
func (client *Client) Feed(userId string, count int) ([]FeedPhoto, error) {
response, err := client.Request("photos.getContactsPublicPhotos", Params{
"user_id": userId,
"count": fmt.Sprintf("%d", count+1),
})
if err != nil {
return nil, err
}
raw := &FeedRaw{}
err = Parse(response, raw)
if err != nil {
return nil, err
}
feed := []FeedPhoto{}
for _, photo := range raw.Photos.Photo {
feed = append(feed, FeedPhoto{
Id: photo.Id,
Title: photo.Title,
Owner: photo.Owner,
OwnerName: photo.Username,
Secret: photo.Secret,
Server: photo.Server,
Farm: photo.Farm,
})
}
return feed, nil
}