Access-Control-Allow-Origin with instagram api

后端 未结 1 1142
逝去的感伤
逝去的感伤 2020-12-07 02:53

I am trying to get my instagram feed with the following code

$.ajax({
      url: \'https://api.instagram.com/v1/users/xxxxxxx/media/recent/?access_token=xxxx         


        
相关标签:
1条回答
  • 2020-12-07 03:55

    Instagram API supports JSONP, so add &callback=? to the url and add dataType: "jsonp" to the $.ajax() call, like below:

    $.ajax({
          url: 'https://api.instagram.com/v1/users/xxxxxxx/media/recent/?access_token=xxxxxxxxxxx&callback=?',
    
          error: function() {
            alert('error');
          },
    
          success: function(data) {
           alert('yes');
          },
          type: 'GET',
          dataType: "jsonp"
       });
    
    0 讨论(0)
提交回复
热议问题