gpt4 book ai didi

PHP 的 cURL : How to connect over HTTPS?

转载 作者:可可西里 更新时间:2023-11-01 13:05:35 24 4
gpt4 key购买 nike

我需要使用常规 URL 编码查询字符串对 EC2 查询 API 执行简单的 GET 请求。协议(protocol)是 HTTPS。我将如何借助 PHP 的 cURL 发送请求。

最佳答案

例子:

$url = "https://example.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);

$result = curl_exec($ch);
curl_close($ch);

print_r($result);

CURLOPT_SSL_VERIFYPEER

检查对等证书是否有效或无效/过期。

CURLOPT_SSL_VERIFYHOST 引自 php manual :

1 to check the existence of a common name in the SSL peer certificate. 2 to check the existence of a common name and also verify that it matches the hostname provided.

关于PHP 的 cURL : How to connect over HTTPS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2306196/

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