cURL响应无法读取

时间:2015-06-06 01:08:17

标签: php curl

我的cURL响应有问题,当我尝试调用WSDL方法时,我从浏览器收到这个奇怪的文本,

�d�ْ�<�_��[�7�4eS�@���8 �]��Q��A���>�t�,����]�1��%Y���4!l�^ZG��,8��v��������#ZJ�W��
r)0Ek����Q�����"Ᏹ�!�0��0����(�T�$���� Z��փ��UU���g������&�C�f
8�!��5��L�t{����6�?{jY�Q��?���K����3�D2�e   �߱Oc����@^P��$�IΠ�4A[;�p�\7�����i5��+�\歖~=����)�����a�L�GJey�F����Ɍ��v]��<��z������N����\z��.�i:�S5��FgkM�hS���|,\�0�E9i=�+ӄ�!^WҶ�7�����0�w���+b�۹��[�;���fE4_ڑ�������u�Q)E��;�;�JL���������Ԩ�1��7[�$D���\�W���ۂU$9���

我该如何解决这个问题?

这是我的标题

$headers = array(
                "Accept-Encoding: gzip, deflate",
                "Content-Type: text/xml;charset=\"UTF-8\"",
                "SOAPAction: \"http://tempuri.org/"",
                "Host: domain.com",
                "Content-length: ".strlen($xml_post_string),
                "Connection: Keep-Alive"
                ); 

这是我的卷曲选项

curl_setopt($soap_do, CURLOPT_URL,            $url);
curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($soap_do, CURLOPT_TIMEOUT,        120);
curl_setopt($soap_do, CURLOPT_AUTOREFERER,    true); // new
curl_setopt($soap_do, CURLOPT_MAXREDIRS,      10);   // new
curl_setopt($soap_do, CURLOPT_FOLLOWLOCATION, true); // new
curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($soap_do, CURLOPT_POST,           true );            
curl_setopt($soap_do, CURLOPT_POSTFIELDS,     $xml_post_string); 
curl_setopt($soap_do, CURLOPT_VERBOSE,        TRUE); 
curl_setopt($soap_do, CURLOPT_HTTPHEADER,     $headers);

2 个答案:

答案 0 :(得分:3)

谢谢你们的评论,我现在已经解决了这个问题,向Grokify大喊,我只是删除了Accept-Encoding: gzip, deflate,现在它已经可读了。

答案 1 :(得分:-1)

我遇到了类似的问题。添加工作标题(从我的浏览器开始)为我解决了这个问题。

我的当前工作代码:

$headers = array("User-Agent: ********User Agent********");
$ch = curl_init("******URL*******");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$data= curl_exec($ch);
curl_close($ch);