Davincible / goinsta

Unofficial Instagram API written in Golang (v2022)
MIT License
181 stars 54 forks source link

Doubt about order of users returned by Followers and Followings. #33

Closed obalunenko closed 2 years ago

obalunenko commented 2 years ago

Could you please clarify what is current order of users list that is returned by Followers and Followings methods? Is it possible to change the order according to date when user appeared at followers and followings?

I'm asking cause when I'm using application I can change at least the order of Followings by the date.

Davincible commented 2 years ago

This wasn't implemented yet, but after your question I implemented it!

You can now change the order of the following (not followers, as the app doesn't allow that). Also implemented the search query in the first argument.

// Or goinsta.EarliestOrder
users := insta.Account.Following("", goinsta.LatestOrder)
obalunenko commented 2 years ago

Thanks for your job, that is really cool! Can't wait to see this in a new release to use this functionality in my service😄

Davincible commented 2 years ago

You can already use it!

I didn't create a release but I did tag it, if you update it to v3.2.3 you have it :D

obalunenko commented 2 years ago

That's great!

But I'm a little bit confused about version tag change. Seems that these changes breaks current functionality and at least minor tag should be changed. Or maybe it will be better to make arguments to Following method optional to keep other's code not broken after update to newer version?

Davincible commented 2 years ago

Hm yeah that is true. I usually tend to create small increment tags to release smaller commits. But you're right that might be better to not that for breaking changes

obalunenko commented 2 years ago

@Davincible we have a problem... I tried a latest tag v3.2.3 and all requests for fetching followers with empty query just hanged for forever. Account.Followers("") I rolled back to v3.2.2 and checked request for fetching followers - got response successfully almost immediately. Tried again tag v3.2.3 - the same endless hang. I decided to wait some time and finally received Request Status Code 400: fail, challenge_required And found that my account was blocked as it was marked as account with credentials shared with service for growing amount of followers and likes.

Could this be caused with changes in how queries passed to requests to instagram? Maybe these queries are not supposed to be sent with request from mobile app and that's why they made a decision that these requests are illegal?

Davincible commented 2 years ago

Uhoh that doesn't sound good, let me check

Davincible commented 2 years ago

@obalunenko After analyzing, compared to the prev version the only redundant added GET param is includes_hashtags, if I run the tests that simply fetch insta.Account.Followers("") it returns instantly, not sure why it doesn't for you.

I'll fix this. Are you sure that's the only thing that's changed? I'd find it extreme of IG to not return at all only due to one extra param, but possible ofc

obalunenko commented 2 years ago

@Davincible thanks for investigation. Yeah, I'm pretty sure that this is only the change that I added in my code that is executed before sending the request.

I forgot to mention that I also iterate over the Users to get details for each user (username, id, fullname).

    users := insta.Account.Followers("")

    for users.Next() {
        for i := range users.Users {
            u := users.Users[i]

            // get details here
        }
    }

    if err := users.Error(); err != nil {
        if !errors.Is(err, goinsta.ErrNoMore) {
            // handle error
        }
    }
Davincible commented 2 years ago

@obalunenko for this particular test that you ran, did you run over your home network or either a VPN, server, or proxy?

I've also noticed some new header values, that might also have to do with it, but will need to research that a bit more.

obalunenko commented 2 years ago

@Davincible I used home network for running this test. And usually I don't use VPN or proxy servers when using this SDK via my tool

Davincible commented 2 years ago

@obalunenko I see, that's good. Be careful with running on non-residential IPs, that gets your account blocked. Same goes for GitHub CI, if you run anything there it goes through over their server IPs != residential.

Just pushed a new update, can you try v3.2.5, and see if it works for you?