Tampilkan postingan dengan label belajar. Tampilkan semua postingan
Tampilkan postingan dengan label belajar. Tampilkan semua postingan

Selasa, 09 Oktober 2012

Menampilkan RSS dengan php

langsung aja ini adalah contoh script php untuk memangil rss

<?php
// FEED RSS yang mau dipanggil
$feed = curl_init('http://rss.detik.com/index.php/detikcom');
curl_setopt($feed, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($feed, CURLOPT_HEADER, 0);
$xml = simplexml_load_string(curl_exec($feed));
curl_close($feed);

//cek feed
if ($xml!=''){
$tampil = 5;
$counter = 1;
foreach ($xml->channel->item as $item){

// membuat variabel permalink, judul, deskripsi
$link = $item->link;
$judul = $item->title;
$description = $item->description;


// tampilkan
echo '<p><b><a href="'.$link.' ">'.$judul.'</a></b><br />'.$description.'</p>';
if ($counter == $tampil) break;
else $counter++;
}}
?>

scrip di atas adalah contoh menampilkan rss detik.com