連續動作:
$ch = curl_init();
curl_setopt($ch , CURLOPT_URL, 'https://YourSite/rss');
curl_setopt($ch , CURLOPT_RETURNTRANSFER , true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$result = curl_exec($ch);
$output = array();
$xml = @simplexml_load_string($result);
if (isset($xml->channel) && isset($xml->channel->item)) {
foreach($xml->channel->item as $item) {
$date = date_parse((string)$item->pubDate);
array_push($output, array(
'date' => date('Ymd', mktime(0, 0, 0, $date['month'], $date['day'], $date['year'])),
'title' => (string)$item->title,
'link' => (string)$item->link,
'content' => (string)$item->children('http://purl.org/rss/1.0/modules/content/')->encoded,
'thumbnail' => null,
));
}
}
沒有留言:
張貼留言