我有以下代码,并想知道如何使以下cURL连接以“1.1.1.1:80”格式通过代理
我已尝试过以下操作,但即使使用无效的代理,连接似乎仍然有效,这意味着它必须没有通过代理。
感谢您的帮助!
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>";
}
}
答案 0 :(得分:1)
这不起作用,因为您的函数无法访问 $proxy
变量。
像这样添加内容
function checkPlayer($player) {
$proxy = "1.1.1.1:80"; //<--- Here