차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판이전 판
다음 판
이전 판
tech:simplepie [2013/05/01 01:14] V_Ltech:simplepie [2016/07/12 09:26] (현재) – 바깥 편집 127.0.0.1
줄 1: 줄 1:
 +{{tag>simplepie freeware php opensource 라이브러리}}
 +======심플파이 (Simplepie) - RSS리더======
 +
 +RSS를 긁어올 수 있는 오픈소스임. 설정이 간편하지만 기능은 막강함.
 +
 +  * [[http://simplepie.org/|simple pie]]
 +
 +<code php><?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></code>
 +===== 속도=====
 +좀 느린 것 같다. 
 +피드 두개 불러오는데 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을 쓰도록 함.
 +
 +
 + 
 +
 +