Windows MAMP - PHP CURL问题

Windows MAMP  -  PHP CURL问题

问题描述:

I'm having issues with Windows MAMP Pro 3.3.1 getting PHP's CURL to work.

More specifically issue is that I can send requests to APIs using curl_exec, but it always returns false.

When I tried to do the same thing with XAMPP it returns full response with no issues.

I tried changing PHP version, I checked that php curl extensions is enabled and I can see CURL info in phpinfo.

Does any one know why and how to fix this issue with MAMP?

我遇到了Windows MAMP Pro 3.3.1让PHP的CURL工作的问题。 p>

更具体的问题是我可以使用curl_exec向API发送请求,但它总是返回false。 p>

当我尝试使用XAMPP做同样的事情时它会返回完整的响应 没有问题。 p>

我尝试更改PHP版本,我检查了php curl扩展已启用,我可以在phpinfo中看到CURL信息。 p>

任何人都知道为什么以及如何使用MAMP解决这个问题? p> div>

So I've seen the issue. Apparently (still need to investigate), a CURL request does not get the certificate from the browser, unlike HTTPS. We'll need to manually download the certificate of the site and add it to the PHP ini.

I got the certificate from here:

https://curl.haxx.se/ca/cacert.pem

Add the path to php.ini. You should see ;curl.cainfo under [curl]. Uncomment and add the path:

curl.cainfo = "path_to_cert\cacert.pem"

Restart apache and it'll work (at least mine did).