0

我需要从此 URL 检索 XML 内容:

http://www.ardmasr.com/MasrenaRss.aspx?Category=4

总是返回一个没有任何错误的空字符串,代码:

$curl = curl_init();
curl_setopt ($curl, CURLOPT_CONNECTTIMEOUT,10);
curl_setopt ($curl, CURLOPT_USERAGENT,'smartic-rss-feeds');
curl_setopt ($curl, CURLOPT_URL, $url);
curl_setopt ($curl, CURLOPT_TIMEOUT,120);
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0);
if($curlFollowRedirects){
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
}
$content = curl_exec($curl);
// Check if any error occurred
if($content === false)
{
    echo 'Curl error: ' . curl_error($curl);
}
curl_close ($curl);
// if there is a redirect
if(preg_match('#Location: (.*)#',$content, $r)){
$l = trim($r[1]);
$content = $this->fetch_data($l);
}
return $content;
4

1 回答 1

0

我在编码 URL 时遇到的问题我使用这个函数来解决我的问题:

utf8_decode($url)

于 2013-06-09T10:28:10.837 回答