【问题标题】:Get tagged photo without access token在没有访问令牌的情况下获取标记的照片
【发布时间】:2013-09-13 15:01:20
【问题描述】:

我对此有一些问题。我可以在不获取任何代码或访问令牌的情况下从 Instagram api 获取公开标记的照片吗?

请分享任何链接以供阅读,因为我找不到任何链接。我觉得对网络上的 Instagram api 了解较少。

谢谢!

【问题讨论】:

  • 您是否尝试过阅读Instagram API 文档?请特别注意身份验证部分。
  • 是的,但我认为它没有提到它......
  • 所以你没有读到这句话:“在大多数情况下,Instagram 的 API 只需要使用 client_id”?文档很清楚。

标签: api access-token instagram


【解决方案1】:

我使用 MeteorJS 并调用一个方法服务器端,该方法基本上返回 instagram 页面的“查看源代码”。因此,如果您可以在标签 url 上运行服务器端抓取,您将能够使用下面的内容处理响应,并将所有图像推送到数组中。

//服务器端方法

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

//客户端逻辑

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)

})

【讨论】:

    【解决方案2】:

    无需认证即可通过标签拉取公共媒体。

    查看 get /tags/tag-name/media/recent 端点的 API 文档。这是网址:http://instagram.com/developer/endpoints/tags/#get_tags_media_recent

    文档可能会令人困惑,它在示例中显示为此端点使用 access_token,但这不是必需的。您需要注册一个应用程序并获得一个客户端 ID。

    【讨论】:

    猜你喜欢
    • 2013-10-18
    • 2022-11-24
    • 1970-01-01
    • 1970-01-01
    • 2012-04-30
    • 2012-02-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-28
    相关资源
    最近更新 更多