###クロスドメインブログのRSS取得
Google Feed APIの廃止に伴い、Google Feed APIの代替として
外部サイトのRSS情報をPHPで取得してjQueryで表示させる方法等を試しています。
参考サイトを見ながら試しているのですがなかなかうまくいきません。
現在の方法では背景以外が表示されないというエラーが発生しました。
###背景以外表示不可
###該当のソースコード
<?php $url = "http://ichifuji8.blog.fc2.com/?xml"; $xml = file_get_contents($url); header("Content-type: application/xml; charset=UTF-8"); print $xml; ?>
$(function() { $.ajax({ url: 'rss.php', xmlType: 'xml', success: function(xml) { var row = 0; var data = []; var nodeName; var output = $('#rss'); // start item 成形 $(xml).find('item').each(function() { data[row] = {}; $(this).children().each(function() { nodeName = $(this)[0].nodeName; data[row][nodeName] = {}; attributes = $(this)[0].attributes; for (var i in attributes) { data[row][nodeName][attributes[i].name] = attributes[i].value; } data[row][nodeName]['text'] = $(this).text(); }); row++; }); // end item 成形 output.wrapInner('<ul></ul>'); for (i in data) { output.find('ul').append('<li><a href="' + data[i].link.text + '">' + data[i].title.text + '</a>' + data[i].description.text + '</li>'); // console.log (data[i]); } } }); });
###エラーコード
[Violation] Avoid using document.write().
[Violation] Parser was blocked due to document.write(<script>)
A Parser-blocking, cross site (i.e. different eTLD+1) script, https://www.google.com/uds/?file=feeds&v=1, is invoked via document.write. The network request for this script MAY be blocked by the browser in this or a future page load due to poor network connectivity. If blocked in this page load, it will be confirmed in a subsequent console message.See https://www.chromestatus.com/feature/5718547946799104 for more details.
###補足情報(言語/FW/ツール等のバージョンなど)
これ以外に代替え案があれば知恵をお貸しください。
ブログはFC2です。
質問文のコードはそれぞれコードブロックで囲んでいただけませんか? ```(バッククオート3つ)で囲み、前後に改行をいれるか、コードを選択して「<code>」ボタンを押すとコードブロックになります。また、エラーはエラー文をそのままコードブロックで追記してください。
エラーは出ていませんか?デベロッパーツールで確認してみてください。http://eng-entrance.com/javascript-display-error
エラー内容が記述のコードのものと違います。もう一度確認してみてください。