문서의 이전 판입니다!


심플파이 (Simplepie) - RSS리더

RSS를 긁어올 수 있는 오픈소스입니다. 설정이 간편하지만 기능은 막강합니다.

<?php
$feed_no=7;   //갯수
include_once('./sp/autoloader.php');   // 심플파이 가져오기.
include_once('./sp/idn/idna_convert.class.php');
$feed2 = new SimplePie();    //객체 생성
$feed2->set_feed_url('http://feeds.feedburner.com/VLBB');   //주소 설정
if (!empty($_GET['force']) && $_GET['force'] ===== 'true') { $feed2->force_feed(true);}
$success = $feed2->init();   //실행!
$feed2->handle_content_type();  //처리!
?>
  <div class="rss_recent" >
   <?php if ($success): ?>
    <div class=" " align="center">
     <h3 class="header"><?php if ($feed2->get_link()) echo '<a href="' . $feed2->get_link() . '">'; echo $feed2->get_title(); if ($feed2->get_link()) echo '</a>'; ?></h3>
    </div>
<center>
<table >
    <!-- Let's begin looping through each individual news item in the feed. -->
    <?php foreach($feed2->get_items(0,$feed_no) as $item): ?>
     <tr class="" >
      <td class="ellips" title="<?php echo $item->get_content();  //Display the item's primary content.?>"><?php if ($item->get_permalink()) echo '<a class="ellips" href="' . $item->get_permalink() . '">'; echo (mb_strlen($item->get_title(),"UTF-8")>25)?mb_substr($item->get_title(),0,25,"UTF-8").'...':$item->get_title(); if ($item->get_permalink()) echo '</a>'; ?></td><td class="footnote"><?php echo $item->get_date('j M Y, g:i a'); ?></td>
       </tr>
    <?php endforeach; ?>
   <?php endif; ?>
</table></center>
  </div>

속도

좀 느린 것 같습니다. 피드 두개 불러오는데 1초 걸림..캐쉬도 있는데…

Magpie Simplepie
Light Weight Too Many Files.
Simple Implementation Complex Implemenation
Easy to modify Difficult to modify.
Less time to parse Delay in parsing.
Less documentation but enough Good documented.

Cache

 $feed->set_cache_location('mysql://username:password@hostname:port/database');
캐쉬 방법 속도 테스트
flatfile 0.658 seconds in processing this page.
mysql 0.149 seconds in processing this page.

훨씬 빠른 mysql을 쓰도록 합니다.

누구나 수정하실 수 있습니다. 위키 사용법 참고하세요.

역링크