Get instagram's video media source using oembed endpoints

后端 未结 3 1293
一向
一向 2021-02-03 15:04

THE CONTEXT

I have a piece of (jQuery) ajax code that has been happily working for about 9 months until the last couple of weeks or so.

This code uses Instagr

3条回答
  •  梦如初夏
    2021-02-03 15:36

    I am not a jQuery expert. Putting aside the syntax error(s), could this be any use?

    var publicUrl = "http://instagram.com/p/dAu7UPgvn0"; //photo
    var publicUrl = "http://instagram.com/p/mOFsFhAp4f"; //video
    
    
    var URL = "http://api.instagram.com/oembed?url="+publicUrl;
    
    $(document).ready(function () {
        $.ajax({
            url: URL,
            publicurl: publicUrl,
            dataType: "jsonp",
            cache: false,
            success: function (response) {
                success: function (response) {
                    var mediaSrc;
                    if (response.type === 'photo') {
                        mediaSrc = response.url;
                    } else {
                        mediaSrc = $(publicurl).find('div.Video vStatesHide Frame').src;
                    }
                    console.log(mediaSrc);
                }
            },
            error: function () {
                console.log("couldn't process the instagram url");
            }
        });
    });
    

提交回复
热议问题