how to use multiple proxies in curl?

4.1k views Asked by At

this question is already asked here but there is no speciaifc answer.

The PHP function below fetches a page using a given proxy. Can i use curl to fetch a page using two proxies? eg: i can fetch the page http://example.com using proxy x.x.x.x:x what i'd like to do is, fetch page http://example.com using proxy x.x.x.x:x but the the x.x.x.x:x should be connected thorough y.y.y.y:y (my server->proxy1->proxy2->destination )

    function fetchPage($proxy, $url, $timeout) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_PROXY, $proxy);   
        curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);

        $result = curl_exec($ch);

        curl_close($ch);

        return $result;
    }
0

There are 0 answers