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.
You need to tell cURL the proxy is a SOCKS5 proxy, otherwise cURL assumes it's an HTTP proxy:
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
From the docs:
CURLOPT_PROXYTYPE
Either CURLPROXY_HTTP (default) or CURLPROXY_SOCKS5.
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);
since cURL 7.21.7, you can use CURLOPT_PROXY
and specify the SOCKS protocol:
curl_setopt($ch, CURLOPT_PROXY, 'socks5://bob:marley@localhost:12345');
More informations in the libcurl documentation.