gpt4 book ai didi

PHP curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false) 太慢

转载 作者:行者123 更新时间:2023-12-04 21:49:40 24 4
gpt4 key购买 nike

我使用此方法获取 facebook api 数据。只是一个搜索查询。但我发现使用 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);curl 时间内花费更多时间(超过 10 秒以上)。

有没有其他curl方法可以运行得更快?

注意:我现在在本地主机上测试

$url = "https://graph.facebook.com/search?access_token=".$token."&q=dallas&type=post&scope=publish_stream,offline_access,user_status,read_stream";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 2);
//curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__). '/file.crt'); the way as Lumbendil recommend, download a crt file via firefox. still slowly.
$body= curl_exec($ch);
curl_close ($ch);

PS:我不想使用SDK,因为我在localhost测试中设置SDK失败了。虽然我看了很多关于如何在localhost中设置的文章。我已将 http://127.0.0.1/facebook 设置为我的回调 url。但只是失败了。所以还是想搞个简单的curl方式。

谢谢。

最佳答案

您可以使用 .crt 文件并对其进行验证,而不是忽略 SSL 验证,as explained here .

要将所有信息保存在一个地方:在您的代码中,您应该编写以下内容:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, '/path/to/crt/file.crt');

要获取证书,您应该使用浏览器进入该页面,然后使用“查看证书”将其导出。请记住,您必须将其导出为 X.509 证书 (PEM) 才能正常工作。有关如何导出证书的更详细指南,请访问提供的链接。

关于PHP curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false) 太慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6324391/

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