tw 脚を楽しみたい
..

ハダカのブログ                IP: 3.17.6.75

feedcreator.class.phpでRSS配信

mySQLなどのデータベースにデータがあるのであれば、自分好みのRSSを作成することが可能です。SQL文で必要なデータを取得し、RSSフィード生成ライブラリであるfeedcreator.class.phpを使って生成し出力します。超簡単ですが、RSSを利用するのは自分だけではありません。攻撃対象となり、思わぬトラブルが発生する可能性があることだけは留意しておこう。

RSSを用意するから好きにしてと言う行為は危険なのだぁ

feedcreator.class.phpの一番シンプルな利用例
define('TIME_ZONE', '+09:00');

require_once '/path/to/feedcreator.class.php';

$creator = new UniversalFeedCreator();
$creator->useCached();
$creator->title = 'タイトル';
$creator->description = '説明文';
$creator->link = 'http://example.com/';
$creator->syndicationURL = 'http://example.com/feed.xml';

// 記事を1つ追加
$item = new FeedItem();
$item->title = '記事のタイトル';
$item->link = 'http://example.com/articles/sample';
$item->description = '記事の短い説明';
$item->date = '2007-06-06T12:00:00+09:00';
$item->author = '記事の著者名';

$creator->addItem($item);

// ファイルとして保存する場合
$creator->saveFeed('ATOM1.0', 'feed.xml');

// ファイルに保存せずに出力する場合
// $creator->outputFeed('ATOM1.0');

pr
Copyright(c) 2007 ハダカのブログ