试图读取活的rss,但它返回相同的xml [英] trying to read live rss, but its returning same xml
本文介绍了试图读取活的rss,但它返回相同的xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从http://synd.cricbuzz.com/score-gadget/gadget-scores-feed.xml读取xml文件我理解它的缓存问题,所以我已经添加了no-cache但stil其返回相同文件:(
I am trying to read xml file from "http://synd.cricbuzz.com/score-gadget/gadget-scores-feed.xml" I understand its caching issue so i have added no-cache but stil its returning same file :(
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Pragma: no-cache"); Header('Pragma: no-cache');
$url = "http://synd.cricbuzz.com/score-gadget/gadget-scores-feed.xml";
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($curl);
curl_close ($curl);
print $result;
$fp = fopen('score.xml', 'w');
if($fp)
fwrite($fp, $result);
else
echo "Error !";
$url = "score.xml";
$xml = simplexml_load_file($url);
var_dump($xml);
?>
推荐答案
尝试设置以下选项以阻止缓存: p>
Try setting the following options to prevent caching :
curl_setopt($curl, CURLOPT_FORBID_REUSE, 1);
curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);
这篇关于试图读取活的rss,但它返回相同的xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文