Skip to content

Instantly share code, notes, and snippets.

@fajarlabs
Last active January 11, 2016 08:29
Show Gist options
  • Save fajarlabs/8856629 to your computer and use it in GitHub Desktop.
Save fajarlabs/8856629 to your computer and use it in GitHub Desktop.
<?php
function listen_feed($site,$url_feed){
$data = curl_init(); // inisialisasi CURL
curl_setopt($data, CURLOPT_RETURNTRANSFER, 1); // setting CURL
curl_setopt($data, CURLOPT_URL, $url_feed); // menjalankan CURL untuk membaca isi file
$hasil = curl_exec($data);
curl_close($data);
$kodeHTML = $hasil;
$pecah = explode('<pubDate>', $kodeHTML);
$pecahLagi = explode('</pubDate>', $pecah[1]); // Meng-Explode XML pada PubDate
echo "Website : ".$site."<br />";
echo $jam = substr($pecahLagi[0],17,8);
echo "<br />";
echo $tanggal = substr($pecahLagi[0],5,11);
}
// Cara menggunakan fungsi listenfeed
listen_feed('http://bappeda.depok.go.id','http://bappeda.depok.go.id/rss.xml');
echo '<br />';
listen_feed('http://humas.depok.go.id','http://humas.depok.go.id/feed/');
echo '<br />';
listenfeed('http://pkk.depok.go.id','http://pkk.depok.go.id/?feed=rss2');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment