composerでrss-phpを入れます。
[vagrant@localhost app]$ curl -sS https://getcomposer.org/installer | php All settings correct for using Composer Downloading... Composer (version 1.6.5) successfully installed to: /home/vagrant/app/composer.phar Use it: php composer.phar [vagrant@localhost app]$ php composer.phar require dg/rss-php Using version ^1.2 for dg/rss-php ./composer.json has been created Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 1 install, 0 updates, 0 removals - Installing dg/rss-php (v1.2): Loading from cache Writing lock file Generating autoload files [vagrant@localhost app]$ ls composer.json composer.lock composer.phar index.php vendor
rss-phpでfetchします。
require_once 'vendor/dg/rss-php/src/Feed.php'; $rss = Feed::loadRss('http://hpscript.com/rss/rss.xml'); foreach($rss->item as $item){ echo $item->title ."<br>"; }
301リダイレクトを設定しているURLをfetchします。
require_once 'vendor/dg/rss-php/src/Feed.php'; $rss = Feed::loadRss('http://phone-search.online/test/index.php'); foreach($rss->item as $item){ echo $item->title ."<br>"; }
OK つまり、301リダイレクトで、フィードのURLが変わっても、旧URLに301リダイレクトをかけている間は、新URLのフィードを取得できる。