1

I am posting this question here because I know I will found an answer, as you helped me in my previous issues.

I am trying to access a website using proxy server and I am using this code:

function getPage($proxy,$proxyauth, $url, $referer, $agent, $header, $timeout) {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_HEADER, $header);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_PROXY, $proxy);
            curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
            curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);

            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
            curl_setopt($ch, CURLOPT_USERAGENT, $agent);

            $result['EXE'] = curl_exec($ch);
            $result['INF'] = curl_getinfo($ch);
            $result['ERR'] = curl_error($ch);
            $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
            curl_close($ch);
            return $result; 
    }
$agent2 = 'Opera/9.80 (Series 60; Opera Mini/7.1.32444/35.2883; U; ru) Presto/2.8.119 Version/11.10';
$result = getPage(
        "209.164.74.72:9786", // use valid proxy
        'username:pass',
        "http://www.whatismyip.com/",
        $agent2,
        0,
        5);
echo $result['EXE'];

it's working fine when I use it on my localhost but when I run it online its displaying me an error
couldn't connect to host

I am using hostgator shared server, also tried it on justhost shared server. but same error

1 Answer 1

1

You may try to contact your provider directly http://support.hostgator.com/articles/specialized-help/technical/curl

It is possible that curl is allowed only for HTTP(s) and other ports are not allowed.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.