diff --git a/users.go b/users.go index d9cef137..76a2dcc7 100644 --- a/users.go +++ b/users.go @@ -4,6 +4,7 @@ import ( "encoding/json" "errors" "fmt" + "strconv" ) // Users is a struct that stores many user's returned by many different methods. @@ -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 { @@ -51,15 +52,19 @@ 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 { @@ -67,7 +72,7 @@ func (users *Users) Next() bool { 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