开发者

Warnings using curl

$dm_post = 'DATA=' . urlencode('<?xml version="1.0" encoding="ISO-8859-1"?><REPORTE><NROCTA>1098670</NROCTA><DETALLE><CONSULTA><CLAVE>123456</CLAVE><TIPO>1</TIPO><OPERACIONES><ID>123456789</ID></OPERACIONES></CONSU开发者_StackOverflowLTA></DETALLE></REPORTE>');       

$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, $dm_url);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $dm_post);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);

$info = simplexml_load_string($buffer, 'SimpleXMLElement', LIBXML_NOCDATA);

print_r($info);

Warning: simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found in /var/www/domain.com/public_html/curl_test.php on line 15

Warning: simplexml_load_string(): 1 in /var/www/domain.com/public_html/curl_test.php on line 15

Warning: simplexml_load_string(): ^ in /var/www/domain.com/public_html/curl_test.php on line 15

any ideas? i dunno why i'm getting errors


Looks like you need to set the cURL option CURLOPT_RETURNTRANSFER to true.

curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);

http://php.net/curl_setopt

Default behavior is for curl_exec() to output data directly. By turning on that option, it returns the data as a string instead, which appears to be what you're expecting.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜