简体   繁体   中英

How to access the Instagram API as a script not an app?

There's lots of documentation on how to create an App, and use OAuth to authorise your App's users to access Instagram … but I don't have third-party users. I just want to script access to the API to get data, the way I can with Twitter or Reddit.

Am I missing something obvious?

You can use in this way. Here I am getting all the data from a hashtag. Visit the link to get more on this.

$(document).ready(function () {  
    var hashtag = 'dilwale'// My hash tag  
    var accessToken = '16741082.1b07669.121a338d0cbe4ff6a5e04543158a4f82' //Write your access token  
    $.ajax({  
        url: 'https://api.instagram.com/v1/tags/' + hashtag + '/media/recent?count=33&access_token='+ accessToken +'',  
        dataType: 'jsonp',  
        type: 'GET',  
        success: function (data) {  
            console.log(data);  
            for (x in data.data) {  
                if (data.data[x].type == 'video') {  
                    //console.log("Video" + data.data[x].videos.standard_resolution.url);  
                    //See the browser console and add data as per requirements  
                    $('.instagram').append('<div style="border:1px solid orange"><video controls><source src="' + data.data[x].videos.standard_resolution.url + '" type="video/mp4"></video><span style="border:1px solid orange; dislay:block">Test1</span></div>');  
                } else if (data.data[x].type == 'image') {  
                    $('.instagram').append('<div style="border:1px solid orange"><img src="' + data.data[x].images.standard_resolution.url + '" ><span style="border:1px solid orange; display:block">"' + data.data[x].caption.text + '"</span><span style="border:1px solid orange; dislay:block">Test1</span></div>');  
                    //console.log("Image");  
                    //See the browser console and add data as per requirements  
                }  
            }  
        },  
        error: function (data) {  
            console.log(data);  
        }  
    })  
}); 

Find solution in fiddle Get latest images and videosfrom a hash tag

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM