Recv失败:在Curl PHP中重置了连接

时间:2016-04-12 13:37:50

标签: php apache http curl

我想使用http post by xml从12.96.12.174这个ip地址获取一些数据 我为那个

创建了curl php代码
 <?php
$url = "http://12.96.12.174";
$post_string = '<?xml version="1.0"?>
<CRMAcresMessage>
<Header ImmediateResponseRequired="true" OriginalBodyRequested="true">
<MessageID>25</MessageID>
<TimeStamp>2016-03-11T011:35:11</TimeStamp>
<Operation Operand="Request" Data="PlayerProfile" />
</Header>
<PlayerID>59979</PlayerID>
<Body>   
</Body>
</CRMAcresMessage>';
$header  = "POST HTTP/1.0 \r\n";
$header .= "Content-type: text/xml \r\n";
$header .= "Content-length: ".strlen($post_string)." \r\n";
$header .= "Content-transfer-encoding: text \r\n";
$header .= "Connection: close \r\n\r\n"; 
$header .= $post_string;
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL,$url);
//$fp = fopen('rss.xml', 'w');
curl_setopt($ch,CURLOPT_PORT, 8085);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST,  $header);
echo $data = curl_exec($ch);
if(curl_errno($ch))
print curl_error($ch);
else
curl_close($ch);
?>

当我从&#34; http://examle.com`/members/check.php"点击该链接时;这个网址给了我Recv失败:连接被重置为Curl这条消息

从我的localhost我无法连接

php版本也是&gt; 5.3

我是Curl的初学者,请帮忙解决这个问题

1 个答案:

答案 0 :(得分:1)

curl_setopt($ch, CURLOPT_URL, trim($url));
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

对于Recv失败:在Curl PHP中重置连接==&gt; 声明如下:

CURLOPT_SSL_VERIFYPEER as 0 

&安培;确保您使用的是PHP版本&gt; 5.3