繁体   English   中英

从卷曲请求到https服务器没有响应

[英]No Response getting from Curl Request to https server

我正在创建对服务器的PHP curl请求,并期望响应中包含一些字符串,但没有响应生成,这可能是什么原因?

下面是相同的Curl代码:

$fields = array("username"=> 'xxx',"domain"=> 'xxx',"password" => 'xxx');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://host:8090/add-user"); 
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);     
curl_setopt($ch, CURLOPT_USERPWD, $usr.':'.$pass);
curl_setopt($ch, CURLOPT_POST, 1);      
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);   
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);    
if(!$result=curl_exec($ch)){ 
    trigger_error(curl_error($ch)); 
} 
curl_close($ch);
var_dump($result);

下面是相同的等效命令行请求:

curl --data 'username=xxx&domain=xxx&password=xxx' https://host:8090/add-user -k -v -u 'usr:pass'

我在做什么错这里?

您应该首先尝试使用curl_setopt($ch, CURLOPT_VERBOSE, $file_handler); 其中$file_handler = fopen('somefile.log', 'a') 因此,您将看到cURL的确切功能以及失败的地方。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM