fork download
  1. <!DOCTYPE html>
  2. <html lang="ja">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>タイトル</title>
  6. <link rel="stylesheet" type="text/css" href="style.css">
  7. </head>
  8. <body>
  9.  
  10.  
  11. <?php
  12. //対象URLのサイトの配信しているRSSフィードを取得する
  13. $curl = curl_init(); ///////////////////////////////スタート宣言と初期化
  14. curl_setopt($curl, CURLOPT_URL, 'http://b...content-available-to-author-only...r.jp/dqnplus/index.rdf'); /////RSSのURL
  15. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); ////////// 1はtrue
  16. curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); //////////頑張る秒数
  17. $str = curl_exec($curl); ////////////////////////// $str にRSSの内容を代入
  18. curl_close($curl); ////////////////////////// 終了
  19. $feed = simplexml_load_string($str);//XML文字列をオブジェクトに代入
  20.  
  21. echo "<pre>";
  22. //echo htmlspecialchars($str);//XML解析用(コメントアウトを外すとコードが表示)
  23. //フィードタイトル
  24. echo "</pre>";
  25.  
  26. //6つのアイテムを取得
  27. for($i=0;$i<=5;$i++){
  28. $entry = $feed->channel->item[$i];
  29. echo $entry->link;
  30. /*
  31.   echo "<image src='";
  32.   echo $entry->enclosure->attributes()->url;
  33.   echo "'>";
  34.   echo "<a href='";
  35.   echo $entry->link;
  36.   echo "'>";
  37.   echo $entry->title;
  38.   echo "</a>";
  39. echo $entry->pubDate . "<br />";
  40. */
  41. }
  42. ?>
  43.  
  44. </body>
  45. </html>
Success #stdin #stdout #stderr 0.04s 24832KB
stdin
Standard input is empty
stdout
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>タイトル</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
	<body>

	
	<pre></pre>
</body>
</html>
stderr
PHP Notice:  Trying to get property 'channel' of non-object in /home/zqdOnp/prog.php on line 28
PHP Notice:  Trying to get property 'item' of non-object in /home/zqdOnp/prog.php on line 28
PHP Notice:  Trying to get property 'link' of non-object in /home/zqdOnp/prog.php on line 29
PHP Notice:  Trying to get property 'channel' of non-object in /home/zqdOnp/prog.php on line 28
PHP Notice:  Trying to get property 'item' of non-object in /home/zqdOnp/prog.php on line 28
PHP Notice:  Trying to get property 'link' of non-object in /home/zqdOnp/prog.php on line 29
PHP Notice:  Trying to get property 'channel' of non-object in /home/zqdOnp/prog.php on line 28
PHP Notice:  Trying to get property 'item' of non-object in /home/zqdOnp/prog.php on line 28
PHP Notice:  Trying to get property 'link' of non-object in /home/zqdOnp/prog.php on line 29
PHP Notice:  Trying to get property 'channel' of non-object in /home/zqdOnp/prog.php on line 28
PHP Notice:  Trying to get property 'item' of non-object in /home/zqdOnp/prog.php on line 28
PHP Notice:  Trying to get property 'link' of non-object in /home/zqdOnp/prog.php on line 29
PHP Notice:  Trying to get property 'channel' of non-object in /home/zqdOnp/prog.php on line 28
PHP Notice:  Trying to get property 'item' of non-object in /home/zqdOnp/prog.php on line 28
PHP Notice:  Trying to get property 'link' of non-object in /home/zqdOnp/prog.php on line 29
PHP Notice:  Trying to get property 'channel' of non-object in /home/zqdOnp/prog.php on line 28
PHP Notice:  Trying to get property 'item' of non-object in /home/zqdOnp/prog.php on line 28
PHP Notice:  Trying to get property 'link' of non-object in /home/zqdOnp/prog.php on line 29