RSSを表示させるPHPスクリプト(RSS2HTML)
RSSからHTMLを作成するのに便利なのが、RSS2HTMLだ。
FeedForAll has made available a free PHP program called rss2html.php, which can be used by webmasters to automatically display RSS feeds on their website. The resulting webpage will always show the RSS feed's most current data. The advantage of using the rss2html.php script is that the resulting webpage's contents will always be up to date, and can be easily spidered by search engines.
つまりは、PHPスクリプトを利用してRSSとテンプレートHTMLを読み込み、ブラウザで表示可能な形式に変換するという代物である。
自分のサーバにrss2html.phpを設置して利用する場合、以下の2つの利用方法がある。どちらにせよ、まずFeedForAllのダウンロードページより、rss2html.zipをダウンロードし、適当な場所に解凍しておく。
解凍してできるのは、以下の3つのファイル
以下、インストールメモ。(2通りの利用方法があります)
(1) Syntaxを利用して、rss2html.phpへアクセスする場合
- rss2html.phpとsample-template.htmlをサーバにアップロード
- 以下の部分を、それぞれの環境に合わせて編集してアクセスする
http://<your-domain>/rss2html.php?XMLFILE=<your-rss-feed
>&TEMPLATE=<your-template>&MAXITEMS=<maxitems>
- '<your-domain>' :
自分のドメイン - '<your-rss-feed>' :
表示したいRSSへのfull URL
(i.e. http://www.mydomain.com/myfeed.xml) - '<your-template>' :
テンプレートファイルへのfull URL
(i.e. http://www.mydomain.com/sample-template.htm) - '<max-items>' :
RSS feedから読み込みたい項目のMax数
- '<your-domain>' :
(2) rss2html.phpを編集して、rss2html.phpに直接アクセスする場合
- rss2html.phpをエディタで開き、以下の3箇所を編集する
- rss2html.phpを保存して、テンプレートファイルと共に、サーバへアップロード
- http://(あなたのドメイン)/rss2html.php にアクセス
もし、自分のサーバがPHPを使えない場合は、FeedForAllの公開サーバに設置してあるrss2html.phpを利用することが出来るようだ。この方法については、RSS2HTMLのDocumentationをご覧下さい。
また、ここでは長くなるので触れないが、sample-template.htmlの内容も自由にカスタマイズすることが出来る。自分で編集するのも可能だし、Layout Optionsのページには、数多くのテンプレートが用意してある。このあたりは、MTチックな感じがする。
このスクリプトは、使い方によっては色々なことが出来る。とりあえず自分は、FlickrのRSSを読み込んで、最近アップロードした写真のリストを表示してみた。こんな感じ。
Free RSS to HTML PHP Script
http://www.feedforall.com/free-php-script.htm