<?php // ライブラリの読み込み require_once "./Feed.php" ; // 取得するフィードのURLを指定 $url = "http://yamanakasawao.com/y/podcast/feed" ; // インスタンスの作成 $feed = new Feed ; // RSSを読み込む $rss = $feed->loadRss( $url ) ; // HTML表示用 $html = '' ; foreach( $rss->item as $item ) { // 各エントリーの処理 $title = $item->title ; // タイトル $link = $item->link ; // リンク $description = $item->description ; // 詳細 // 日付の取得(UNIX TIMESTAMP) foreach( array( "pubDate" , "date_timestamp" , "dc:date" , "published" , "issued" ) as $time ) { if( isset( $item->{ $time } ) && !empty( $item->{ $time } ) ) { $timestamp = ( is_int( $item->{ $time } ) ) ? $item->{ $time } : strtotime( $item->{ $time } ) ; break ; } } // 仮に日付が取得できなかったらとりあえず現在時刻でも…(笑) if( !isset( $timestamp ) ) { $timestamp = time() ; } // 表示 $html .= '<a href="' . $link . '">' . $title . '</a> (' . date( "Y/m/d H:i" , $timestamp ) . ')<br>' ; } ?><!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="robots" content="noindex,nofollow"> <!-- ビューポートの設定 --> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>PHPでRSSフィードを取得するサンプルデモ</title><!-- /******************************************************************************** SYNCER 〜 知識、感動をみんなと同期(Sync)するブログ * 配布場所 https://syncer.jp/php-how-to-get-feed * 動作確認 https://syncer.jp/php-how-to-get-feed/demo/get-feed.php * 最終更新日時 2015/09/14 00:35 * 作者 あらゆ ** 連絡先 Twitter: https://twitter.com/arayutw Facebook: https://www.facebook.com/arayutw Google+: https://plus.google.com/114918692417332410369/ E-mail: info@syncer.jp ※ バグ、不具合の報告、提案、ご要望など、お待ちしております。 ※ 申し訳ありませんが、ご利用者様、個々の環境における問題はサポートしていません。 ********************************************************************************/ --> </head> <body> <?php echo $html ?> <p style="text-align:center"><a href="https://syncer.jp/php-how-to-get-feed">配布元: Syncer</a></p> </body> </html>