phpでRSSの読み込み等に利用するライブラリmagapieがあるが
このmagpieのライセンスはGPLライセンスである
でGPLライセンスの場合
プログラムの全部あるいは一部を用いて作られたソフトウェアはGPLに従って頒布されることが条件となっているので商用ソフトウェアではなかなか利用しづらい
そこで他のライセンスのライブラリが無いか探してみると
simplepieというのがあるようなので
必要に応じてこちらを利用しようと思う
simple pieはBSDライセンスのようなので
(利用時は該当バージョンのライセンスの確認をしてください)
結構自由に使えちゃう
※ライセンスについては
http://www.gnu.org/licenses/license-list.ja.htmlを参照
<?php
require_once 'simplepie.inc';
include_once 'functions.php';
define('RSS_FILE2', 'rss_summary_properties.txt');
$code = "UTF-8";
$rss_properties = file(RSS_FILE2);
if (!is_array($rss_properties)){
echo "no data";
exit;
}
$feed = new SimplePie($url);
$i =0;
foreach ($rss_properties as $url) {
$feed->set_feed_url($url);
$feed->init();
$feed->handle_content_type();
$ch[$i]['blog_title'] = $feed->get_title();
foreach ($feed->get_items() as $item ) {
$ch[$i]['title'] = $item->get_title();
$ch[$i]['created'] = $item->get_date('Y-m-d H:i:s');
$link_array = $item->get_links();
$ch[$i]['link'] = $link_array[0];
$i++;
}
}
//usort($ch, "cmp"); //別functionで日付の比較
echo "<ul>";
for ($i = 0; $i <= 5; $i++) {
$title = mb_convert_encoding(strip_tags($ch[$i]['title']), $code, "UTF-8,EUC-JP,SJIS");
if(isset($ch[$i]['created'])){
$date = strtotime(str_replace("T", " ", substr($ch[$i]['created'], 0, 19)));
$date = date("Y/m/d",$date);
}else{
$date = "";
}
$url = $ch[$i]['link'];
echo "<li><a href=" . $url . " >" . $title . "</a>" . $date . "</li>\n";
}
echo "</ul>";
?>
こんな感じにするとrss_summary_properties.txtってファイルに書き込んだ
URLリストを取得してリスト形式で表示できる