Sending POST request with CURL and proxies

254 views Asked by At

I've been trying to fix this all day but I haven't been able to figure out the solution. I am trying to post a request to a website through my website on a php file. I am using curl and would like to use proxies, however I am not getting any response. I am with namecheap and even had them look into it and they can't seem to figure it out either. I got them to open port 8080 and no success.

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_PROXY, $proxy );
    curl_setopt($ch, CURLOPT_PROXYPORT, $port );
    curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 0 );
    curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 0);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURL_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    $response = curl_exec($ch);
    echo $response;

This is my code which will not give me a response. When I sending this without any proxies it goes through and I get a response.

1

There are 1 answers

3
Daniel Stenberg On BEST ANSWER

Reading the error code code and message from a failed function call is a good idea as it might give you a clue about what's going on.

The PHP documentation for CURLOPT_PROXTYPE doesn't include 'HTTP' as a valid type. It does list CURLPROXY_HTTP though.