Home  >  Article  >  Backend Development  >  What to do if php curl download fails

What to do if php curl download fails

藏色散人
藏色散人Original
2021-03-12 17:58:082611browse

php curl download failed solution: first open the corresponding PHP file; then add "curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);" and other code statements and save the changes.

What to do if php curl download fails

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

The reason why PHP CURL cannot be downloaded, https Site

Use php curl to download, http site can, but https site cannot capture the content.

Solution

Add 3 lines

 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
 curl_setopt($ch, CURLOPT_CAINFO, \Yii::getAlias('@app/config/cacert.pem'));

Download cacert.pem

Download address: https://curl.haxx .se/docs/caextract.html

[Recommended learning: "PHP Video Tutorial"]

The above is the detailed content of What to do if php curl download fails. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn