Where do I find the Instagram media ID of a image

后端 未结 15 1382

I\'m am looking for the MediaID of an Instagram image which has been uploaded. It should look like

1234567894561231236_33215652

15条回答
  •  伪装坚强ぢ
    2020-12-22 20:16

    Here's a better way:

    http://api.instagram.com/oembed?url=http://instagram.com/p/Y7GF-5vftL/
    

    Render as json object and you can easily extract media id from it ---

    For instance, in PHP

    $api = file_get_contents("http://api.instagram.com/oembed?url=http://instagram.com/p/Y7‌​GF-5vftL/");      
    $apiObj = json_decode($api,true);      
    $media_id = $apiObj['media_id'];
    

    For instance, 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){}   
        } 
    });
    

提交回复
热议问题