-
Notifications
You must be signed in to change notification settings - Fork 1
/
following.go
51 lines (40 loc) · 848 Bytes
/
following.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
package flickr
import "fmt"
type FollowingRaw struct {
Contacts struct {
Contact []struct {
IconFarm int
IconServer string
Ignored int
NSID string
RevIgnored int
Username string
}
}
}
func (client *Client) Following (userId string) ([]User, error) {
response, err := client.Request("contacts.getPublicList", Params{
"user_id": userId,
})
raw := &FollowingRaw{}
err = Parse(response, raw)
if err != nil {
return nil, err
}
following := []User{}
ids := make(map[string]bool)
for _, user := range raw.Contacts.Contact {
if _, ok := ids[user.NSID]; ok {
fmt.Println(user.NSID)
panic(user.NSID)
}
ids[user.NSID] = true
following = append(following, User{
Id: user.NSID,
Title: user.Username,
IconFarm: user.IconFarm,
IconServer: user.IconServer,
})
}
return following, nil
}