ahmdrz / goinsta

Unofficial Instagram API written in Golang
MIT License
895 stars 247 forks source link

How to get media via URL parameter #233

Closed vec715 closed 5 years ago

vec715 commented 5 years ago

Hi, i`m trying to find current media via URL param in function

// full url is: https://www.instagram.com/p/BpTDvkgl4MS/
m, err := insta.GetMedia("BpTDvkgl4MS") 
if err != nil {
    panic(err)
}
fmt.Println(m)

But i see next: panic: fail: Media not found or unavailable () How i can get media item via url?

ahmdrz commented 5 years ago

You have to convert it to media_id. #100

mediaID, err := goinsta.MediaIDFromShortID("BpTDvkgl4MS")
if err != nil {
    panic(err)
}
media, err := insta.GetMedia(mediaID) 
if err != nil {
    panic(err)
}
fmt.Println(media)