【问题标题】:Instagram API: getting users feed from another siteInstagram API:从另一个站点获取用户提要
【发布时间】:2015-07-04 16:12:31
【问题描述】:

我正在尝试获取某个用户发布的最后几张照片。

在这个网站上,我发现很多答案都说可以在没有身份验证令牌的情况下执行此操作(例如,How can I get a user's media from Instagram without authenticating as a user?)。

每当我在浏览器上打开 https://api.instagram.com/v1/users/search?q=cocacola&client_id=5c314c67157f4585ba3041281540c59b 时,我都会收到一个有效的 json 响应。但是当我在我的站点中对 javascript 执行 get 请求时,它会失败。

编辑:供将来参考,该问题与跨域请求有关。

【问题讨论】:

    标签: javascript jquery json authentication instagram


    【解决方案1】:

    你需要使用jsonp,例如:

    $.ajax({
        url: "https://api.instagram.com/v1/users/search?q=cocacola&client_id=5c314c67157f4585ba3041281540c59b", 
        // Tell jQuery we're expecting JSONP
        dataType: "jsonp",
        success: function( response ) {
            console.log( response ); // server response
        }
    });
    

    -DEMO-

    【讨论】:

    • 我怎么没有意识到这一点。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-26
    • 2020-02-16
    • 1970-01-01
    • 2020-02-12
    • 1970-01-01
    • 1970-01-01
    • 2021-10-08
    相关资源
    最近更新 更多