CORS错误,当我使用instagram API与angularjs

CORS error, when i use instagram API with angularjs

本文关键字:instagram API angularjs 错误 CORS      更新时间:2023-09-26

我有简单的任务-从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);
    });

但是我总是得到这个错误信息:

对预飞行请求的响应未通过访问控制检查:No"访问-控制-允许-起源"标头出现在请求上资源。起源的http://project。因此不允许访问Loc '。响应的HTTP状态码为405。

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

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

这里是另一个Stack Overflow问题的链接,它解释了如何使用angular的jsponp