-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfriend.go
44 lines (37 loc) · 874 Bytes
/
friend.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
package tindergo
import (
"encoding/json"
"errors"
)
type Friend struct {
UserID string `json:"user_id"`
Name string `json:"name"`
Photo []struct {
ProcessedFiles []struct {
URL string `json:"url"`
Height int `json:"height"`
Width int `json:"width"`
} `json:"processedFiles"`
} `json:"photo"`
InSquad bool `json:"in_squad"`
}
type FriendResponse struct {
Status int `json:"status"`
Results []Friend `json:"results"`
}
func (t *TinderGo) Friends() ([]Friend, error) {
fr := FriendResponse{}
url := "https://api.gotinder.com/group/friends"
b, errs := t.requester.Get(url)
if errs != nil {
return fr.Results, errs[0]
}
err := json.Unmarshal([]byte(b), &fr)
if err != nil {
return fr.Results, err
}
if fr.Status != 200 {
return fr.Results, errors.New("Error getting Facebook Friends.")
}
return fr.Results, nil
}