【发布时间】:2014-12-21 20:45:37
【问题描述】:
我正在尝试使用 PHP 从 URL 获取 xml 内容,但我尝试的所有方法都返回空字符串或错误。网址为:http://www.bmfbovespa.com.br/Pregao-Online/ExecutaAcaoAjax.asp?CodigoPapel=NATU3|PETR4|ITSA4|
首先,我尝试使用 simplexml_load_file,并收到错误消息。然后我尝试使用 file_get_contents,但返回为空。
最后,我使用 cURL,使用以下命令:
$ch=curl_init();
$timeout=5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
// Get URL content
$lines_string=curl_exec($ch);
// close handle to release resources
curl_close($ch);
但也没有返回任何内容。谁能帮帮我?
【问题讨论】:
-
我试了一下,得到的 XML 没有错误。
标签: php url curl file-get-contents