Angular和FlickrAPI交叉起源错误

时间:2014-04-13 21:17:03

标签: angularjs flickr

任何人都可以告诉我为什么在运行这些API请求时出现此错误?

错误: XMLHttpRequest无法加载仅支持HTTP的跨源请求。

photographyServices.factory('Flickr', function($http, $resource, $q, appAlert,    flickrConfig) {    
  return {
    myFaves: function() {
      var flickrUrl = $resource('https://api.flickr.com/services/rest/', 
      { method: 'flickr.photos.search', api_key: flickrConfig.apiKey, user_id: flickrConfig.myId, sort: 'date-taken-desc',
        extras: 'description, url_c, date_taken', format: 'json', jsoncallback: 'JSON_CALLBACK' }, 
      { 'load': { 'method': 'JSONP' } });
      var q = $q.defer();
      flickrUrl.load({
        tags: 'fave'
      }, function(resp) {
        q.resolve(resp);
      }, function(err) {
        q.reject(err);
      })

      return q.promise;
    },

    myGalleries: function() {
      var flickrUrl = $resource('https://api.flickr.com/services/rest/', 
      { method: 'flickr.photosets.getList', api_key: flickrConfig.apiKey, user_id: flickrConfig.myId,
        format: 'json', jsoncallback: 'JSON_CALLBACK' }, 
      { 'load': { 'method': 'JSONP' } });
      var q = $q.defer();
      flickrUrl.load({
      }, function(resp) {
        q.resolve(resp);
      }, function(err) {
        q.reject(err);
      })

      return q.promise; 
    }
  }
});

0 个答案:

没有答案