綺麗にスタイルされたRSSを簡単に吐けるPHPクラスライブラリ「RSS74」
2008年02月08日
スポンサード リンク
PHP classes
綺麗にスタイルされたRSSを簡単に吐けるPHPクラスライブラリが公開されています。
(「RSS74」という名前で公開されているものです)
PHPでRSSを吐くのはXMLを組み立てるだけで簡単だけど、ブラウザで見た場合にも綺麗に表示できる、スタイルされたものを吐きたい場合はちょっと大変。
ということで、スタイルされたRSSを吐くPHPクラスライブラリの登場です。
次図のようなブラウザで閲覧してもスタイルされたRSSが吐けます。
ソースは次のように、オブジェクト指向で分かりやすい記述が可能です。
オブジェクトに配列を渡してあげるだけです。
<?php
include('inc.rss74.php');
// RSS items list:
$example_list = array();
/*
** Create some test entries:
*/
$example_list[] = array(
'title' => 'Example RSS message #1',
'url' => 'http://www.example.org/?1',
'desc' => 'This is the first example message ! You can use <b>html</b>.',
'date' => mktime(0, 0, 0, 12, 17, 2006) // Dez. 17, 2006
);
$example_list[] = array(
'title' => 'Example RSS message #2',
'url' => 'http://www.example.org/?2',
'desc' => 'This is second example message ! You can use <b>html</b>.',
'date' => mktime(0, 0, 0, 12, 18, 2006) // Dez. 18, 2006
);
$example_list[] = array(
'title' => 'Example RSS message #3',
'url' => 'http://www.example.org/?3',
'desc' => 'This is third example message ! You can use <b>html</b>.',
'date' => mktime(0, 0, 0, 12, 19, 2006) // Dez. 19, 2006
);
// create new RSS object:
$rss = new rss74();
/*
** Set RSS informations:
*/
// RSS title:
$rss->title = 'RSS example 1';
// RSS description:
$rss->desc = 'This feed shows some static feed entries.';
// base URL of your homepage:
$rss->base_url = 'http://www.example.org/';
// limit entry count to 20
$rss->limit_entries = 20;
// Set Feedburner adress:
//$rss->feedburner_url = 'http://feeds.feedburner.com/codedump-rss';
// (empty) = No redirection
// Set "xsl_file" to empty to disable the XSL file
//$rss->xsl_file = '';
// Add entries to the RSS object:
while (list($date, $entry) = each($example_list)){
$rss->add_entry(array(
'title' => $entry['title'],
'url' => $entry['url'],
'desc' => $entry['desc'],
'date' => $entry['date']
));
}
// let rss74 do the rest:
$rss->print_rss();
?>
PHPでRSSを吐く際に1つの選択肢として覚えておきましょう。
関連エントリ
スポンサード リンク
投稿者 KJ : 2008年02月08日 07:05
|
![]()
間違いの指摘をしていただける方はメールでお願いします
最新のブログ記事
- 2008年8月29日 管理人のブックマーク
- 全キャリア対応のデコメールの作成・変換が可能なPHPライブラリ「Qdmail」
- プロフェッショナルなノートパソコンの広告風画像を作る流れ
- 歯車や雲、人型など実用的なPhotoshopブラシ集
- 2008年8月28日 管理人のブックマーク
- オープンソースの便利PHPスクリプトまとめサイト「Open Source PHP」
- 表示法が新しくセクシーなLightBox「SexyLightBox」
- 背景画像やテクスチャ画像のリソース13サイト
- 2008年8月27日 管理人のブックマーク
- Ajaxベースのクールなショッピングカート作成
- WEBで好きな曲を共有可能な音楽共有オープンソース「Opentape」


















