How to use a SOCKS 5 proxy with cURL?

后端 未结 3 1012
梦毁少年i
梦毁少年i 2020-12-24 13:49

Normal proxies (ex: 72.41.132.22:3128) work well with cURL, however when I use SOCKS 5 proxies with username/pass, It just gives me \"[1\" on the page.

3条回答
  •  生来不讨喜
    2020-12-24 14:41

    For those looking to connect via a hostname(localhost?), and it's not working with CURLPROXY_SOCKS5, you can try CURLPROXY_SOCKS5_HOSTNAME.

    curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME);
    

    In some earlier PHP versions, you will have to do:

    curl_setopt($ch, CURLOPT_PROXYTYPE, 7);
    

提交回复
热议问题