Skip to content
This repository has been archived by the owner on Aug 25, 2023. It is now read-only.

implement UserTaggedFeed() #97

Merged
merged 2 commits into from
Feb 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions goinsta.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,28 @@ func (insta *Instagram) UserFeed(userID int64, maxID, minTimestamp string) (resp
return resp, err
}

// UserTaggedFeed - Returns the feed for medua a given user is tagged in
func (insta *Instagram) UserTaggedFeed(userID int64, maxID, minTimestamp string) (response.UserFeedResponse, error) {
resp := response.UserFeedResponse{}

body, err := insta.sendRequest(&reqOptions{
Endpoint: fmt.Sprintf("usertags/%d/feed/", userID),
Query: map[string]string{
"max_id": maxID,
"rank_token": insta.Informations.RankToken,
"min_timestamp": minTimestamp,
"ranked_content": "true",
},
})
if err != nil {
return resp, err
}

err = json.Unmarshal(body, &resp)

return resp, err
}

// MediaComments - Returns comments of a media, input is mediaid of a media
// You can use maxID for pagination, otherwise leave it empty to get the latest page only.
func (insta *Instagram) MediaComments(mediaID string, maxID string) (response.MediaCommentsResponse, error) {
Expand Down
28 changes: 28 additions & 0 deletions goinsta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,34 @@ func TestUserFeedWithMaxIDAndTimestamp(t *testing.T) {
t.Log("Finished")
}

func TestUserTaggedFeed(t *testing.T) {
if skip {
t.Skip("Empty username or password , Skipping ...")
}

_, err := insta.UserTaggedFeed(17644112, "", "") // ID from elonmusk
if err != nil {
t.Fatal(err)
return
}
time.Sleep(3 * time.Second)
t.Log("Finished")
}

func TestUserTaggedFeedWithMaxIDAndTimestamp(t *testing.T) {
if skip {
t.Skip("Empty username or password , Skipping ...")
}

_, err := insta.UserTaggedFeed(17644112, "25025320", "25025320") // ID from elonmusk
if err != nil {
t.Fatal(err)
return
}

t.Log("Finished")
}

func TestSearchTags(t *testing.T) {
if skip {
t.Skip("Empty username or password , Skipping ...")
Expand Down