无法加载资源:net :: ERR_CONNECTION_REFUSED仅适用于来自Instagram API的选择性图像

问题描述 投票:4回答:1

我目前正在向instagram API发出GET请求以获取带有特定标记的一堆照片,并将我在Rails中获得的JSON对象返回给JS中的调用者,并使用img链接和缩略图等设置HTML。在DOM中。

奇怪的是,重新启动我的服务器后,我收到此错误:

Failed to load resource: net::ERR_CONNECTION_REFUSED 

仅适用于Instagram API返回的部分但不是全部照片。

  var formdata = {tag: "myflsadventure"};
 $.ajax({
    url: "application/get_instagram_photos",
    type: "POST",
    datatype: 'json',
    data: formdata,
    success: function(response){
     htmlz = "<div class='container'><div class='row'>";
      count = 0;
      rounded_style = " style='border:1px solid #; -webkit-border-radius: 20px; -moz-border-radius: 20px; border-radius: 20px;'"
      $.each(response.data, function(i, item) {
        if (count == 0 ){
          htmlz += "<div class='col-md-6'><img src='"+item.images.standard_resolution.url+ "'" + rounded_style+"></div><div class='col-md-6'><div class='no-top'>";
          count = count + 1;
        }
        else if (count == 9){
          htmlz += "</div><div class='row'><div class='col-md-6'><div class='no-top'><div class='row'><div class='col-md-6'><img src='" + item.images.low_resolution.url+ "'" + rounded_style + "></div>";
          count = count + 1;
         }
        else if (count == 13){
          htmlz += "<div class='col-md-6'><img src='" + item.images.standard_resolution.url+ "'" + rounded_style + "></div></div></div>";
         count = count + 1;
         }
        else if (count ==5){
           htmlz += "</div><div class='row'><div class='col-md-3'><img src='" +item.images.low_resolution.url+ "'" +rounded_style+ "></div>";
          count = count + 1;
        }
         else if ((count == 4) || (count == 12)){
           htmlz += "<div class='col-md-6'><img src='"+item.images.low_resolution.url+ "'" + rounded_style +"></div></div></div></div></div>";
           count = count + 1;
        }
        else if ((count == 6)  || (count == 7) || (count == 8)  ){
           htmlz += "<div class='col-md-3'><img src='"+ item.images.low_resolution.url+ "'" + rounded_style + "></div>";
           count = count + 1;
         }
        else if ((count == 3) || (count == 11)){
           htmlz += "<div class='top'><div class='row'><div class='col-md-6'><img src='" + item.images.low_resolution.url + "'" + rounded_style + " ></div>";
           count = count + 1;
        }
         else if ( count == 1){
           htmlz += "<div class='row'><div class='col-md-6'><img src='" + item.images.low_resolution.url + "'" + rounded_style + " ></div>";
           count = count + 1;
        }
        else{
           htmlz += "<div class='col-md-6'><img src='"+ item.images.low_resolution.url+ "'"+ rounded_style + "></div></div>";
          count = count + 1;
        }
      });
       $("#myflsadventure").append(htmlz);
       reapportion_les_fotos();
    }
    });

这是我的路由,最后是我的控制器,它进行API调用

  post '/application/get_instagram_photos', to: 'school_applications#get_instagram_photos'

控制器方法

  def get_instagram_photos
respond_to do |format|
  uri = URI("https://api.instagram.com/v1/tags/#{params[:tag]}/media/recent?client_id=myIDc&count=14")
  response = Net::HTTP.get(uri)
  format.json {render :json => response}
end

结束

更新:

这只发生在我的开发机器上。在推送到Heroku并从其他计算机查看后,照片加载正常,除了仍然在我的主要工作机器上。它似乎独立于浏览器(尝试过Opera,Firefox,Safari和Chrome)和adblock独立(根据类似SO帖子上的建议,在Chrome上隐藏它)。

javascript jquery instagram-api
1个回答
0
投票

我在我的开发机器上有类似的行为,在编辑我的.htaccess重定向后会出现错误消息。我无法再从同一网络中的任何设备上的任何浏览器访问特定网站(尽管我能够从一些shell命令访问它)。我强烈认为我的路由器存在安全问题并阻止了浏览器对网站的进一步访问。大约24小时后,我再次访问了该网站。

现在问这个问题已经有一段时间了,所以我不会要求你设置相同的环境来测试你是否也有24小时的阈值并进一步澄清问题。

编辑:这是我试图解决问题ERR_CONNECTION_REFUSED exclusively in browsers的问题的链接

© www.soinside.com 2019 - 2024. All rights reserved.