开发者

Warnings using curl

开发者 https://www.devze.com 2023-03-30 17:17 出处:网络
$dm_post = \'DATA=\' . urlencode(\'<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><REPORTE><NROCTA>1098670</NROCTA><DETALLE><CONSULTA><CLAVE>123456</CLAVE&
$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

精彩评论

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