2014-06-29 140 views
-2

哦,你好。通过instagram照片获得用户(标签)

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

  • Theres一种显示Instagram照片+用户名(发布照片的人)的方式?

感谢;)

回答

1

如果我理解正确你的问题,假设你有一个Instagram的图片的URL像http://instagram.com/p/p2P-98uHBp/那么你可以使用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

相关问题