Get tagged photo without access token

安稳与你 提交于 2019-12-11 16:28:40

问题


I have some problem on this. Can I get public tagged photo from Instagram api without getting any code or access token?

Please share any link for reading because I cannot found any. I feel it is less knowledge about Instagram api on web.

Thanks!


回答1:


You can pull public media by tag without authentication.

Take a look at the API documentation for the get /tags/tag-name/media/recent endpoint. Here's the URL: http://instagram.com/developer/endpoints/tags/#get_tags_media_recent

The documentation can be confusing, it shows using an access_token for this endpoint in the example, but it is not required. You will need to register an application and get a client ID.




回答2:


I use MeteorJS and call a method server side that returns essentially the 'view source' of the instagram page. So if you can run a server side scrape on the tag url you will be able to handle the response with what i have below and it will push all the images into an array.

//server side method

Meteor.methods({
'scrapeInst':function(tag){
    return Scrape.url('https://www.instagram.com/explore/tags/'+tag+'/')
}})

//client side logic

Meteor.call('scrapeInst',Session.get('params').tag,function(err,resp){


    var theInstResp = resp;

    cleanOne = resp.replace(/>|window._sharedData = |;<&#47;|;|#47;|<|/g,'').split('script')
    var splitter = cleanOne[22].split(',');
    var theArr = [];


    _.each(splitter,function(e){
        var theFinal = {};
        var theS = e.split(":");


        if(theS[0].replace(/"| |/g,'') === "display_src"){
            theFinal[theS[0].replace(/"| |/g,'')] = theS[2].replace(/%22/g,'');
            theArr.push(theFinal)
        }


    });

    Session.set('photos',theArr);
    setTimeout(function(){
        Session.set('loading',false)
    },1000)

})


来源:https://stackoverflow.com/questions/18709818/get-tagged-photo-without-access-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!