4 Pustaka RSS Parser untuk PHP

January 7th, 20108:43 am

2


Terkadang kita memerlukan data dari RSS yang diambil dari website lain untuk mengolah ataupun mengintegrasikan data tersebut dengan proyek yang kita buat. Kita tentu bisa membuat RSS parser sendiri, tetapi sebelum menghabiskan waktu untuk membuatnya, kita lihat dulu pustaka-pustaka RSS parser yang telah ada.

SimplePie

SimplePie

SimplePie adalah RSS parser yang sangat cepat dan mudah digunakan.

Fitur :

  • 1 file, tidak ada instalasi.
  • Terdapat mekanisme cache.
  • Mempunyai plugin untuk WordPress, Joomla, Drupal dan lainnya.

Contoh penggunaan

1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
    require 'simplepie/simplepie.inc'; 
    $feed = new SimplePie('http://feeds.feedburner.com/komunitaz');
?>
 
<h1><?php print $feed->get_title(); ?></h1>
<ul>
<?php foreach ($feed->get_items(0, 10) as $item): ?>
    <li>
        <a href="<?= $item->get_permalink(); ?>"><?= $item->get_title(); ?></a>
    </li>
<?php endforeach; ?>
</ul>

MagpieRSS

Fitur

  • Mudah digunakan.
  • Parses RSS 0.9 – RSS 1.0
  • Cache yang terintegrasi.
  • HTTP Conditional GETs.
  • Dapat dikonfigurasi.
  • Modular.
  • Aman – mendukung HTTP authentication,dan SSL.
  • Penggunaan bandwidth yang rendah – mendukung transparent GZIP encoding untuk mengurangi penggunaan bandwidth.
  • Tidak menggunakan fopen(), tetap bekerja walau setting allow_url_fopen dimatikan.

Contoh penggunaan

1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
    require('magpierss/rss_fetch.inc');
    $rss = fetch_rss('http://feeds.feedburner.com/komunitaz');        
?> 
 
<h1>Komunitaz</h1>
<ul>
<?php foreach ($rss->items as $item): ?>
    <li>
        <a href="<?= $item['link']; ?>"><?= $item['title']; ?></a>
    </li>
<?php endforeach; ?>
</ul>

RSS_PHP

RSS_PHP adalah RSS parser dan XML parser untuk PHP 5+.

Contoh penggunaan

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
    require 'rss_php/rss_php.php';
    $rss = new rss_php;
    $rss->load('http://feeds.feedburner.com/komunitaz');
    $items = $rss->getItems();        
?> 
 
<h1>Komunitaz</h1>
<ul>
<?php foreach ($items as $item): ?>
    <li>
        <a href="<?= $item['link']; ?>"><?= $item['title']; ?></a>
    </li>
<?php endforeach; ?>
</ul>

Last RSS

Last RSS mengklaim sebagai RSS parser yang sederhana tetapi powerful.

Contoh penggunaan

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
    require('lastRSS/lastRSS.php');	
    $rss = new lastRSS;
    $feed = $rss->get('http://feeds.feedburner.com/komunitaz');
?> 
 
<h1><?= $feed['title'] ?></h1>
<ul>
<?php foreach ($feed['items'] as $item): ?>
    <li>
        <a href="<?= $item['link']; ?>"><?= $item['title']; ?></a>
    </li>
<?php endforeach; ?>
</ul>

Related posts:

  1. Kumpulan Pustaka PHP
  2. flot Pustaka Javascript Plotting untuk jQuery
  3. CakePHP : PHP Web Framework
  4. Drizzle Database Server Untuk Web dan Cloud
  5. Python Untuk Programmer PHP
Tags:  ,