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);
}
The program supposed to fetch all the materials from yahoo rss sites and output them into the tmpFile.
After executed the program, I opened up the tmpFile.txt. It shows
c1.ops.sp1.yahoo.com uncompressed/chunked Wed Apr 11 01:46:41 UTC 2012 –>
This doesn’t look right. I pasted the url http://rss.news.yahoo.com/rss/topstories there are plenty of materials returned.
What you needed was
curl_setopt($curlHandle, CURLOPT_ENCODING , "gzip");….yahoousescompressionfor itsrssfeed …Additional Information Include .
A.
CURLOPT_USERAGENT…. Its nice if you don;t what to start looking like spamB.
CURLOPT_TIMEOUT… Just for effeciencyC.
CURLOPT_FOLLOWLOCATION.. Becasue of issues with clean URL and routesWorking Code
I hope this helps .. let me know if you need anything more