gpt4 book ai didi

PHP cURL 无法正常工作且未显示任何错误

转载 作者:行者123 更新时间:2023-12-03 21:34:49 25 4
gpt4 key购买 nike

下面是我写的代码。但它没有在我的屏幕上显示任何内容。我错过了什么吗?

error_reporting(E_ALL);
ini_set("display_errors", 1);

$reservation_obj['source'] = "website";
$reservation_obj['location_code'] = "test";
$reservation_obj['start_date'] = "2010-06-01 19:00";
$reservation_obj['end_date'] = "2010-06-04 13:50";
$reservation_obj['action'] = "get_quotes";

$json = json_encode($reservation_obj);

$ch = curl_init();

curl_setopt($ch,CURLOPT_URL,"https://myserver/test.php");
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HEADER, true);
curl_setopt($ch,CURLOPT_HTTPHEADER, array('Content-Type: text/json', 'Content-length: '.strlen($json)));
curl_setopt($ch,CURLOPT_POST, true);

curl_setopt($ch,CURLOPT_POSTFIELDS, $json);
curl_setopt($ch,CURLOPT_VERBOSE, false);

curl_setopt($ch,CURLOPT_SSLCERT,getcwd()."key/test_services.pem");
curl_setopt($ch,CURLOPT_SSLCERTTYPE, "PEM");

curl_setopt($ch,CURLOPT_SSLKEY,getcwd()."key/test_services.p12");
curl_setopt($ch,CURLOPT_SSLKEYTYPE, "P12");

curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_SSLVERSION, 3);

$output=curl_exec($ch);

curl_close($ch);

print_r($output);

这是我在打印时得到的
echo "<pre>";
var_dump(curl_getinfo($ch));
echo "</pre>";

下面是我得到的输出。我的服务器需要 ssl 证书,这就是我添加 ssl 内容的原因。如果我错了,请帮助我。
array(26) {
["url"]=>
string(68) "https://myserver/test.php"
["content_type"]=>
NULL
["http_code"]=>
int(0)
["header_size"]=>
int(0)
["request_size"]=>
int(0)
["filetime"]=>
int(-1)
["ssl_verify_result"]=>
int(0)
["redirect_count"]=>
int(0)
["total_time"]=>
float(0.325151)
["namelookup_time"]=>
float(0.124679)
["connect_time"]=>
float(0.400445)
["pretransfer_time"]=>
float(0)
["size_upload"]=>
float(0)
["size_download"]=>
float(0)
["speed_download"]=>
float(0)
["speed_upload"]=>
float(0)
["download_content_length"]=>
float(-1)
["upload_content_length"]=>
float(-1)
["starttransfer_time"]=>
float(0)
["redirect_time"]=>
float(0)
["redirect_url"]=>
string(0) ""
["primary_ip"]=>
string(14) "204.13.111.172"
["certinfo"]=>
array(0) {
}
["primary_port"]=>
int(443)
["local_ip"]=>
string(12) "192.168.1.75"
["local_port"]=>
int(36492)
}

删除后我得到了这个:
rray(26) {
["url"]=>
string(68) "https://wsh.netpark.us/reservation_services/test/ws_reservations.php"
["content_type"]=>
NULL
["http_code"]=>
int(0)
["header_size"]=>
int(0)
["request_size"]=>
int(269)
["filetime"]=>
int(-1)
["ssl_verify_result"]=>
int(0)
["redirect_count"]=>
int(0)
["total_time"]=>
float(2.50114)
["namelookup_time"]=>
float(0.124669)
["connect_time"]=>
float(0.51286)
["pretransfer_time"]=>
float(1.316726)
["size_upload"]=>
float(124)
["size_download"]=>
float(0)
["speed_download"]=>
float(0)
["speed_upload"]=>
float(49)
["download_content_length"]=>
float(-1)
["upload_content_length"]=>
float(124)
["starttransfer_time"]=>
float(0)
["redirect_time"]=>
float(0)
["redirect_url"]=>
string(0) ""
["primary_ip"]=>
string(14) "204.13.111.172"
["certinfo"]=>
array(0) {
}
["primary_port"]=>
int(443)
["local_ip"]=>
string(12) "192.168.1.75"
["local_port"]=>
int(36695)
}

最佳答案

在 curl_exec 命令之后和 curl_close 之前试试这个。那应该打印任何错误。

if($errno = curl_errno($ch)) {
$error_message = curl_strerror($errno);
echo "cURL error ({$errno}):\n {$error_message}";
}

关于PHP cURL 无法正常工作且未显示任何错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27033686/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com