A
A
Alex Alex2015-12-05 14:06:02
PHP
Alex Alex, 2015-12-05 14:06:02

How to make cUrl proxy request with authorization?

<?php
function getContent ($url) { 
    $curl = curl_init($url); 
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); 
    curl_setopt($curl,CURLOPT_RETURNTRANSFER,1); 
    curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)"); 
    curl_setopt($curl, CURLOPT_TIMEOUT, 15); 
    curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30); 
    curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, 1);
    curl_setopt($curl, CURLOPT_PROXY, "94.252.60.10:3128"); 
    curl_setopt($curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
  //curl_setopt ($curl, CURLOPT_PROXYUSERPWD, "gzi1wox:mncu9k1g");
    curl_setopt ($curl, CURLOPT_HEADER, 1);
    $r = curl_exec($curl);  
    curl_close($curl); 
    return $r;  
} 
 
$content = getContent('http://getip.social/'); 
echo $content; 
?>

When I make a request with simple proxies, the request goes away and I get a response from the server, when I try to uncomment the line and make a request with a proxy that has authorization, the server returns a 500 response

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2015-12-05
@Nc_Soft

You need to play around with the CURLOPT_PROXYAUTH parameter

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question