我正在尝试验证 Minecraft 用户名是否已付费。
通过在 URL 末尾输入用户名,它会返回 true 或 false。
$input = 'Notch';
function checkPlayer($player) {
$mcURL = 'http://www.minecraft.net/haspaid.jsp?user=';
$auth = file_get_contents($mcURL . $player);
if ($auth === true) {
echo $player. ' is valid';
} else {
echo $player. ' is not valid';
}
}
checkPlayer($input);
但它不会返回 true。转到页面http://www.minecraft.net/haspaid.jsp?user=Notch ,它确实返回 true。我该如何正确检查?我认为 file_get_contents
对于此事使用的函数是错误的。不过我不确定。
最佳答案
更改此行:
if ($auth === true) {
与
if (trim($auth) == "true") {
关于php - 检查页面返回 true 还是 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10363915/