通过Instagram照片获取用户(标签)

时间:2014-06-29 20:42:56

标签: instagram

哦,你好。

我正在使用instagram api进行实验现在,我可以通过instagram标签显示照片。但我有一个问题:

  • Theres是一种显示instagram照片+用户名(发布照片的人)的方法吗?

谢谢;)

1 个答案:

答案 0 :(得分:1)

如果我正确理解了您的问题,假设您拥有像http://instagram.com/p/p2P-98uHBp/这样的Instagram图片的网址,那么您可以使用Instagam的Embedding Endpoints从该链接获取json信息

此URL格式将返回您需要的json数据:

http://api.instagram.com/oembed?url=http://instagram.com/p/p2P-98uHBp/

用户名可以从ajax响应中提取,如:

var instaURL = "http://api.instagram.com/oembed?url=http://instagram.com/p/p2P-98uHBp/";
$(document).ready(function () {
    $.ajax({
        url: instaURL,
        dataType : "jsonp", // this is important
        cache: false,
        success: function (response) {
            alert("the instagram user is = " + response.author_name);
        },
        error: function () {
            alert("couldn't process the instagram url");
        }
    });
});

参见 JSFIDDLE

相关问题