Answer the question
In order to leave comments, you need to log in
Curl and Proxy - how to check the work?
I want to test proxy via curl.
I bought an anonymous proxy for the test. Checked it in the browser - everything works.
To check the request, I want to send the link - httpbin.org/ip - this service shows the ip of the request server.
The code is like this:
$link = "http://httpbin.org/ip";
$proxy = "77.220.205.245:51604";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $link);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_PROXY, $proxy);
curl_setopt($curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt($curl, CURLOPT_PROXYUSERPWD, '7rV6DLKeD2:plyuto');
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$headers = [
"User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36 OPR/42.0.2393.94", "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"Accept-Charset: utf-8",
"Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4"
],
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($curl, CURLOPT_TIMEOUT, 5);
$content = curl_exec($curl);
return $content;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question