javainstagram

Get location info from a Instagram link


Can I get the information from a Instagram link such as : https://instagram.com/p/7u46R_Ia9X/ I found we can get the information with location id with Instagram API but I don't know to get location ID or location info from a link like above.

Update:We can resolve with under answer, if you don't have a Access token , we can receive with simple link : http://bobmckay.com/web/simple-tutorial-for-getting-an-instagram-clientid-and-access-token/


Solution

  • You first need to get the media-id value for the image, and then use the following endpoint to get the location-id and other related info.

    https://api.instagram.com/v1/media/{media-id}?access_token=ACCESS-TOKEN
    

    The response of this end point returns the location along with all the details of the media.

    Code to get the media id from an instagram url in JS

    $.ajax({     
        type: 'GET',     
        url: 'http://api.instagram.com/oembed?callback=&url=http://instagram.com/p/Y7GF-5vftL‌​/',     
        cache: false,     
        dataType: 'jsonp',     
        success: function(data) {           
            try{              
                var media_id = data[0].media_id;          
            }catch(err){}   
        } 
    });