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

* bug fix on issue 325 #326

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
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
19 changes: 12 additions & 7 deletions users.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"strconv"
)

// Users is a struct that stores many user's returned by many different methods.
Expand All @@ -21,7 +22,7 @@ type Users struct {
BigList bool `json:"big_list"`
Users []User `json:"users"`
PageSize int `json:"page_size"`
NextID string `json:"next_max_id"`
NextID *int `json:"next_max_id"`
}

func newUsers(inst *Instagram) *Users {
Expand Down Expand Up @@ -51,23 +52,27 @@ func (users *Users) Next() bool {

insta := users.inst
endpoint := users.endpoint
query := map[string]string{
"ig_sig_key_version": goInstaSigKeyVersion,
"rank_token": insta.rankToken,
}

if users.NextID != nil {
query["max_id"] = strconv.Itoa(*users.NextID)
}

body, err := insta.sendRequest(
&reqOptions{
Endpoint: endpoint,
Query: map[string]string{
"max_id": users.NextID,
"ig_sig_key_version": goInstaSigKeyVersion,
"rank_token": insta.rankToken,
},
Query: query,
},
)
if err == nil {
usrs := Users{}
err = json.Unmarshal(body, &usrs)
if err == nil {
*users = usrs
if !usrs.BigList || usrs.NextID == "" {
if !usrs.BigList || usrs.NextID == nil {
users.err = ErrNoMore
}
users.inst = insta
Expand Down