我正在嘗試使用jquery-rss來決議博客的 RSS 提要,特別是因為它能夠在 XML 節點內決議嵌套的 HTML 元素(如影像)。我在本地完美地運行了它(具有諷刺意味的是,通常是本地開發給我帶來了最大的 CORS 悲傷):
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>jquery.rss example</title>
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.4/moment.min.js"></script>
<script src="jquery.rss.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script>
jQuery(function($) {
$("#rss-feeds").rss("https://blog.sonelp.com/rss.xml",
{
limit: 3,
layoutTemplate: '<div class="news-items"><div class="row">{entries}</div><div class="view-all col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12"><a href="https://blog.sonelp.com">View archive</a></div></div>',
entryTemplate: '<div class="news-item col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4"><div class="news-head"><a class="news-title" href="{url}">{title}</a><img class="img-fluid" src="{teaserImageUrl}" /><span class="news-date">{date}</span></div><div class="news-body">{shortBodyPlain}</div><div class="buttons"><a href="{url}" class="button-2 btn btn-primary read-more" target="_blank">Read more</div></div>'
})
})
</script>
</head>
<body>
<div id="rss-feeds"></div>
</body>
</html>
但是一旦我將它添加到我的網站,我就會收到以下“混合內容”錯誤:
混合內容:“https://blah.com/”頁面已通過 HTTPS 加載,但請求不安全腳本“http://www.feedrapp.info/?callback=jQuery16409576896732281612_1640639664174&q=https://blog。 sonelp.com/rss.xml&num=3&_=1640639664276'。此請求已被阻止;內容必須通過 HTTPS 提供。
請注意,https它同時用于我嘗試運行此代碼的托管站點和實際的 XML 提要——問題顯然是 jquery-rss 使用相同的開發人員的Feedr替換解決方案來替代 Google 現在已棄用的 Feed API,其中通過http(“...請求一個不安全的腳本' http ://www.feedrapp.info...”)呼叫。我嘗試直接在 jquery-rss 腳本中更正此問題,但無濟于事。關于如何在這里進行的任何想法?
uj5u.com熱心網友回復:
Rory McCrossan 在上面的評論中得到了正確的答案:我必須確保我想要決議的 RSS 提要的 Feedr 呼叫使用的是https,而不是http。花了一些時間,但通過洗掉此腳本中的每個實體ssl和對它的參考,然后確保默認包含的 URL 的建構式修復了我的問題,我不再有混合內容錯誤。https
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/401048.html
