0

I need to access a website from php with curl, but I must use a proxy.

Is there a simple way to set curl to use a proxy?

If there is no simple way, what other options are available?

Please supply a code example

0

1 Answer 1

1

Did you searched already on stackoverflow? You might check this answer How to use CURL via a proxy?

Or doesn't answer this your question?

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.foo.bar');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
curl_setopt($ch, CURLOPT_PROXY, 'proxy:8080');    
curl_setopt($ch, CURLOPT_PROXYPORT, 8080);    
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'domain\user:password');    

curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($ch, CURLOPT_REFERER, 'http://myreferer.com');
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla...');

$result = curl_exec($ch);
$info = curl_getinfo($ch);
$error = curl_error($ch);

curl_close($ch);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.