【メモ】RSSを読み込むときにSimplePieを使ったので覚書
SimplePieとは
https://github.com/simplepie/simplepie
準備
githubからダウンロード
git clone https://github.com/simplepie/simplepie.git
library以下とautoloader.phpを使いたいプロジェクトのところにコピペ
使いたいクラスでrequire_one 'autoloader.php';
操作
// 初期化 $feed = new SimplePie(); // URLセット $feed->set_feed_url('RSS_URL'); // とりあえず日付順に並べる $feed->enable_order_by_date(true); // 取得実行 $success = $feed->init(); if ($success) { // エラー時処理は適宜 } foreach($feed->get_items() as $item) { // 記事URL echo $item->get_permalink(); // 記事タイトル echo $item->get_title(); // 記事要約 echo $item->get_description(); }
とまあ、そんな感じで。