forked from programmingthomas/instago
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrelationship.go
41 lines (37 loc) · 1.19 KB
/
relationship.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
package instago
//Get the list of users this user is followed by.
//
//userID: a string representing the ID (not the username) of a given user
func (api InstagramAPI) UserFollows(userID, cursor string) ([]User, Pagination, error) {
params := getEmptyMap()
if cursor != "" {
params["cursor"] = cursor
}
result := api.DoRequest("users/"+userID+"/follows", params)
data := result.ObjectArray("data")
users := make([]User, 0)
for _, user := range data {
u := UserFromAPI(user)
users = append(users, u)
}
pagination := PaginationFromAPI(result.Object("pagination"))
return users, pagination, api.ErrorFromAPI(result)
}
//Get the list of
//
//userID: a string representing the ID (not the username) of a given user
func (api InstagramAPI) UserFollowers(userID, cursor string) ([]User, Pagination, error) {
params := getEmptyMap()
if cursor != "" {
params["cursor"] = cursor
}
result := api.DoRequest("users/"+userID+"/followed-by", params)
data := result.ObjectArray("data")
users := make([]User, 0)
for _, user := range data {
u := UserFromAPI(user)
users = append(users, u)
}
pagination := PaginationFromAPI(result.Object("pagination"))
return users, pagination, api.ErrorFromAPI(result)
}