TheM4hd1 / SwiftyInsta

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

How to get mediaId from Url or permalink #112

Closed trentona closed 5 years ago

trentona commented 5 years ago

I cant seem to find how to get the mediaId, in order to grab the comments and likes. Could you please clarify on "(as represented in Media.identity.identifier!)" from the previous thread.

// Past comment ok, cool thank you that makes sense. I only have the permalink though, how do I get the mediaId? @sbertix

Originally posted by @trentona in https://github.com/TheM4hd1/SwiftyInsta/issues/34#issuecomment-537627451

TheM4hd1 commented 5 years ago

the media_id can retrieve from handler.media.by we do not provide a function to convert permalink to media_id

handler.media.by(user: .username("sampleusername"), with: .everything, updateHandler: nil) { (result, pagination) in
    switch result {
    case .success(let medias):
        print(medias.first?.identity)
    case .failure(let err):
        print(err)
    }
}