F
F
fashionmens2018-02-19 23:38:59
PHP
fashionmens, 2018-02-19 23:38:59

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;

But for some reason, in the response, I see the ip of my server, but not the ip of the proxy. Can you help me, what am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Ainur Valiev, 2018-02-21
@vaajnur

{
  "origin": "77.220.205.245"
}

such an answer?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question