Get instagram's video media source using oembed endpoints

后端 未结 3 1294
一向
一向 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:32

    This may not be the best or optimum answer , but as i believe this will solve your issue for now , so you may consider it a work around:

    Thanks to whateverorigin.org service we are able to fetch cross origin json , which has all the data you may request , all you have to do is converting the returned object to string , then use regex to fetch whatever data you need.

    var myvideourl="http://instagram.com/p/mOFsFhAp4f/"
    $.ajaxSetup({
        scriptCharset: "utf-8", //maybe "ISO-8859-1"
        contentType: "application/json; charset=utf-8"
    });
    
    $.getJSON('http://whateverorigin.org/get?url=' + 
        encodeURIComponent(myvideourl) + '&callback=?',
        function(data) {
    
            var xx=data.contents
            var dataindex=xx.search('', dataindex);
            var yy=xx.slice(dataindex,end+2)
            var metaobject=$.parseHTML(yy)
            alert(metaobject[0].content)
            console.log(metaobject[0].content)
    });
    

    Here is and example:

    JS Fiddle Demo

    works well for me , but only tried it on the CocaCola video , havent tried it on other links.

提交回复
热议问题