Orca
Orca

Reputation: 73

Make cURL Connect through a Proxy to HTTPS

I have the following code and was wondering how I would make the following cURL connection go through a proxy in the format "1.1.1.1:80"

I have tried the following, but even with an invalid proxy the connection still seems to work meaning it must have not gone through the proxy.

Thank you for the help!

    function checkPlayer($player, $user_sess) {
$resultx = mysql_query("SELECT * FROM proxy
WHERE username='$user_sess' ORDER BY rand() LIMIT 1");
$rowx = mysql_fetch_array($resultx);
$proxy = $rowx['proxy'];
echo "$proxy  Result - ";
ob_flush();
flush();
$mcURL = 'https://www.minecraft.net/haspaid.jsp?user=';
$mcURL = $mcURL.$player;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $mcURL);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_PROXY, $proxy);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); //Add this
$auth = curl_exec($curl);
   if (trim($auth) == "true") {
        echo "Premium<BR>";
ob_flush();
flush();
    }
    else {
    echo "Not Premium<BR>";
    }
}

Upvotes: 0

Views: 223

Answers (1)

That didn't work because $proxy variable is not accessible inside your function.

Add it inside like this

function checkPlayer($player) {
$proxy = "1.1.1.1:80"; //<--- Here

Upvotes: 1

Related Questions