Advertisement
Guest User

Untitled

a guest
Mar 5th, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. <?php
  2. date_default_timezone_set("Asia/Jakarta");
  3.  
  4.  
  5. //$root = simplexml_load_file("http://rss.detik.com/index.php/inet");
  6. //$root = simplexml_load_file("http://rss.nytimes.com/services/xml/rss/nyt/Technology.xml");
  7. //$root = simplexml_load_file("http://rss.cnn.com/rss/edition_asia.rss");
  8. //$root = simplexml_load_file("http://feeds.bbci.co.uk/news/technology/rss.xml?edition=uk");
  9. //$root = simplexml_load_file("http://rss.imdb.com/daily/born/");
  10. //$root = simplexml_load_file("http://rss.imdb.com/daily/died/");
  11. //$root = simplexml_load_file("http://news.nationalgeographic.com/index.rss");
  12. //$root = simplexml_load_file("http://news.nationalgeographic.com/index.rss");
  13. $root = simplexml_load_file("http://gdata.youtube.com/feeds/base/users/lastdayprod/uploads?client=ytapi-youtube-rss-redirect&v=2&orderby=updated&alt=rss");
  14.  
  15.  
  16.  
  17. $title = $root->channel->description;
  18. $link = $root->channel->link;
  19. $guid = $root->channel->guid;
  20. $date = $root->channel->pubDate;
  21.  
  22. $news = array();
  23.  
  24. foreach ($root->channel->item as $data) {
  25. $temp = array();
  26. $temp['title'] = (string)$data->title;
  27. $temp['link'] = (string)$data->link;
  28. $temp['guid'] = (string)$data->guid;
  29. $temp['description'] = (string)$data->description;
  30. $temp['date'] = (string)$data->pubDate;
  31.  
  32. $news[] = $temp;
  33. }
  34. var_dump($news);
  35. ?>
  36.  
  37.  
  38. <html>
  39. <head>
  40. <title>Detik.com Feed</title>
  41. </head>
  42.  
  43. <body>
  44. <h1><a href="<?=$link?>" target="_blank"><?=$title?></a></h1>
  45. <p>Last updated : <?=date("d M Y H:i:s", strtotime($date))?></p>
  46.  
  47. <?php foreach ($news as $data) { ?>
  48. <div style="margin:10px 5px;background:#eee;padding:10px;border-radius:5px;box-shadow:1px 2px 2px rgba(0,0,0,0.5);">
  49. <h3><a href="<?=$data['link']?>" target="_blank"><?=$data['title']?></a></h3>
  50. <p>Publication Date : <?=date("d M Y H:i:s", strtotime($data['date']))?></p>
  51. <div>
  52. <?=$data['description']?>
  53. </div>
  54. </div>
  55. <?php } ?>
  56. </body>
  57. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement