嗨,我试图从 instagram api 获取图像,但我收到错误消息 No 'Access-Control-Allow-Origin'

Hi, I trying to get image from the instagram api, but I am getting an error No 'Access-Control-Allow-Origin'

$(document).ready(function(){


 var paramter = "https://www.instagram.com/nike/media/&callback=?";
  console.log(paramter);
  $.getJSON(paramter ,function(json)

  {
        var birdpic = " ";
        var data = json.items;
        birdpic +="<div class='pics'><img src='"+data[0].images.low_resolution.url+" '></div>";
       $("<div/>").appendTo("#picture").append(birdpic);

  });

});

所以,我尝试将回调添加到末尾https://www.instagram.com/nike/media/q=callback

这样的格式对吗

现在,我得到

jquery-3.1.0.js:9471 
GEThttps://www.instagram.com/nike/media/&callback=jQuery31007809933559544142_1478278811621?_=1478278811622 
send @ jquery-3.1.0.js:9471ajax 
@ jquery-3.1.0.js:8999jQuery.(anonymous function) 
@ jquery-3.1.0.js:9148getJSON 
@ jquery-3.1.0.js:9129(anonymous function) 
@ bird.js:5mightThrow @ jquery-3.1.0.js:3508process @ jquery-3.1.0.js:3576

更改此行:

var paramter = "https://www.instagram.com/nike/media/";

到这一行:

var paramter = "https://www.instagram.com/nike/media/&callback=?";

你使用的API是无证的API,不支持JSONP(回调),所以你要在后台调用,不能使用browser/javascript 拨打 API 个电话。

如果您使用已记录的 APIs,它们都支持 JSONP,您可以使用 ajax

从前端代码访问