![](/img/trans.png)
[英]AxiosError : Failed to load resource: net::ERR_CONNECTION_REFUSED
[英]Failed to load resource: net::ERR_CONNECTION_REFUSED for only selective images from instagram API
我目前正在向 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)和獨立於廣告塊(根據類似 SO 帖子中的建議在 Chrome 隱身模式上嘗試過)。
我在我的開發機器上有類似的行為,在編輯我的.htaccess
以進行重定向后會出現錯誤消息。 我無法再從同一網絡中任何設備上的任何瀏覽器訪問特定網站(盡管我可以通過某些 shell 命令訪問它)。 我強烈認為我的路由器存在安全問題並阻止了瀏覽器對網站的進一步訪問。 大約 24 小時后,我能夠再次訪問該網站。
現在已經有一段時間沒有問這個問題了,所以我不會要求您設置相同的環境來測試您是否也有 24 小時的閾值並進一步澄清問題。
編輯:這是我試圖在瀏覽器中專門解決ERR_CONNECTION_REFUSED問題的問題的鏈接
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.