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

What to do if php curl download fails

藏色散人
Release: 2023-03-08 17:36:01
Original
2649 people have browsed it

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'));
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template