TheM4hd1 / SwiftyInsta

Instagram Private API Swift
MIT License
225 stars 51 forks source link

Total Post,Follower,Following Count #147

Closed arda0011 closed 4 years ago

arda0011 commented 4 years ago

What is the easiest way to get total post, follower and following count in Api?

I tried with below method but it did not return this counts handler.users.user(.me)

sbertix commented 4 years ago

Posts, followers and following count are not exposed to User by design, since those properties are not actually populated every time a User-like object is returned by a request.
You can always access them through the User you get by calling the method you mentioned and then referencing directly the rawResponse.

handler.users.user(.me) {
    guard let user = try? $0.get() else { return }
    let posts = user.rawResponse.mediaCount.int ?? 0
    let followers = user.rawResponse.followerCount.int ?? 0
    let following = user.rawResponse.followingCount.int ?? 0
}

To actually find out all available properties you can do print(user.rawResponse.beautifiedDescription) inside the closure above.