Skip to content

Commit

Permalink
added GetPendingFollowRequests
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmdrz committed Mar 26, 2019
1 parent ffd9e29 commit 9d285d4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 13 deletions.
27 changes: 14 additions & 13 deletions const.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,20 @@ const (
urlFollowing = "friendships/%d/following/"

// users
urlUserByName = "users/%s/usernameinfo/"
urlUserByID = "users/%d/info/"
urlUserBlock = "friendships/block/%d/"
urlUserUnblock = "friendships/unblock/%d/"
urlUserFollow = "friendships/create/%d/"
urlUserUnfollow = "friendships/destroy/%d/"
urlUserFeed = "feed/user/%d/"
urlFriendship = "friendships/show/%d/"
urlUserStories = "feed/user/%d/reel_media/"
urlUserTags = "usertags/%d/feed/"
urlBlockedList = "users/blocked_list/"
urlUserInfo = "users/%d/info/"
urlUserHighlights = "highlights/%d/highlights_tray/"
urlUserByName = "users/%s/usernameinfo/"
urlUserByID = "users/%d/info/"
urlUserBlock = "friendships/block/%d/"
urlUserUnblock = "friendships/unblock/%d/"
urlUserFollow = "friendships/create/%d/"
urlUserUnfollow = "friendships/destroy/%d/"
urlUserFeed = "feed/user/%d/"
urlFriendship = "friendships/show/%d/"
urlFriendshipPending = "friendships/pending/"
urlUserStories = "feed/user/%d/reel_media/"
urlUserTags = "usertags/%d/feed/"
urlBlockedList = "users/blocked_list/"
urlUserInfo = "users/%d/info/"
urlUserHighlights = "highlights/%d/highlights_tray/"

// timeline
urlTimeline = "feed/timeline/"
Expand Down
29 changes: 29 additions & 0 deletions goinsta.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package goinsta
import (
"crypto/tls"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
Expand Down Expand Up @@ -492,3 +493,31 @@ func (inst *Instagram) GetMedia(o interface{}) (*FeedMedia, error) {
}
return media, media.Sync()
}

// GetPendingFollowRequests returns pending follow requests.
func (inst *Instagram) GetPendingFollowRequests() ([]User, error) {
resp, err := inst.sendRequest(
&reqOptions{
Endpoint: urlFriendshipPending,
},
)
if err != nil {
return nil, err
}

var result struct {
Users []User `json:"users"`
// TODO: pagination
// TODO: SuggestedUsers
Status string `json:"status"`
}
err = json.Unmarshal(resp, &result)
if err != nil {
return nil, err
}
if result.Status != "ok" {
return nil, fmt.Errorf("bad status: %s", result.Status)
}

return result.Users, nil
}

0 comments on commit 9d285d4

Please sign in to comment.