我正在尝试提取Feed的内容,但我的代码在此Feed上失败: http://legaltalknetwork.com/RSS/WCM_feed.xml Feed会重定向到http://wcm.ltn.libsynpro.com/rss
如果我在我的代码中使用最终的Feed网址,它可以正常工作,但我需要使用原始网址:http://legaltalknetwork.com/RSS/WCM_feed.xml
这是我的代码:
$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_HEADER, false);
curl_setopt($curl_handle, CURLOPT_URL, $url);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Mozilla');
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 15);
curl_setopt($curl_handle, CURLOPT_TIMEOUT, 10);
curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl_handle, CURLOPT_MAXREDIRS, 10);
$xml = simplexml_load_string(curl_exec($curl_handle));
curl_close($curl_handle);
返回null ... 知道如何解决这个问题吗?