Home  >  Article  >  Backend Development  >  PHP uses CURL proxy problem

PHP uses CURL proxy problem

PHP中文网
PHP中文网Original
2017-03-30 10:45:554040browse

socks5 - PHP uses CURL proxy problem

Use a socket5 proxy to access Google. It works in command line mode, but the PHP code does not work. It returns false directly
The code is posted, please help me solve it

PHP uses CURL proxy problem

PHP uses CURL proxy problemThe proxy string is written as tcp://127.0.0.1:1080Try it,

$ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        if ($this->proxy) {
            curl_setopt($ch, CURLOPT_PROXY, $this->proxy);
        }

The above is the configuration when I did Google, it works normally.

The above is the content of socks5 - PHP using CURL proxy problem. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

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