[PHP] 使用 php 抓取 blogger 的 RSS


記錄一下用 PHP 抓取 blogger RSS 的方法:

//blogger 的 rss feed 連結,即使是已經自訂網址也能使用
$file = "http://[YOUR_BLOGSPOT_ACCOUNT].blogspot.com/atom.xml";
//讀取 RSS
$xml = simplexml_load_file($file) or die ("Unable to load XML file!");
$xml =  $xml ->entry;
foreach( $xml as $row )
/ Load the entry publish time 
 $dtime = date("D jS M, Y", strtotime(strtok($row->published, 'T')));
 // Load the link of each blog entry
 $titlelink = $row->link[4]["href"];
 // Load the text for Comment and comment counts
 $comments = $row->link[1]["href"];
 $comm = $row->link[1]["title"][0]; 

 /* Display the contents (use your own imaginations here =).) */
 // Display blog entry content
 // Display number of comments


參考:How to parse RSS Feed XML from Blogspot using PHP