CORS 错误,当我将 instagram API 与 angularjs 一起使用时

CORS error, when i use instagram API with angularjs

我有一个简单的任务 - 从 Instagram 帐户获取用户数据。我使用标准 instagram api 和 angularjs.

这里是控制器的请求方法:

 $http({
  method: 'GET',
  url: 'https://api.instagram.com/v1/users/6976008122/media/recent/?access_token=1030475459.50cd673.aa04db13898d4fsd9ff8fe5095b32f34&scope=public_content&count=4'
    }).then(function(res) {
      console.log(res);
    }, function(err) {
      console.log(err);
    });

但我总是收到此错误消息:

Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://project.loc' is therefore not allowed access. The response had HTTP status code 405.

前几页Google搜索没有帮助,请帮助我理解并解决这个问题。

使用 jsonp,这里有一个很好的例子:

这是另一个 Stack Overflow 问题的 link,解释了如何用 angular Angular Jsonp

做 jsponp