header('Access-Control-Allow-Origin: *');
$tmpFile = 'tmpFile.txt';
$val="http://rss.news.yahoo.com/rss/topstories";
$curlHandle = curl_init($val);
$filePointer = fopen($tmpFile, "w");
curl_setopt($curlHandle, CURLOPT_FILE, $filePointer);
curl_exec($curlHandle);
curl_close($curlHandle);
fclose($filePointer);
$linesArr = file($tmpFile);
foreach($linesArr as $eachLine){
echo($eachLine);
}
该程序应该从 yahoo rss 站点获取所有材料并将它们输出到 tmpFile。
执行程序后,我打开了 tmpFile.txt。表明
c1.ops.sp1.yahoo.com 未压缩/分块 Wed Apr 11 01:46:41 UTC 2012 -->
这看起来不对。我粘贴了网址http://rss.news.yahoo.com/rss/topstories有很多材料返回。