更新后,Steam身份验证无法正常工作

时间:2018-06-18 23:25:53

标签: php api steam steam-web-api

Steam更新后无法正常工作。可能是什么问题呢? 这是我的代码:

$url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=".$steamauth['apikey']."&steamids=".$matches[1]."";

if (isset($_GET['login'])){
    require 'openid.php';
    try {
        require 'SteamConfig.php';
        $openid = new LightOpenID($steamauth['domainname']);

        if(!$openid->mode) {
            $openid->identity = 'http://steamcommunity.com/openid';
            header('Location: ' . $openid->authUrl());
        } elseif ($openid->mode == 'cancel') {
            echo 'Klaida...';
        } else {
            if($openid->validate()) {
                $id = $openid->identity;
                $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
                preg_match($ptn, $id, $matches);
                include ('userInfo.php');

                $_SESSION['steamid'] = $matches[1];

                $url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=".$steamauth['apikey']."&steamids=".$matches[1]."";
                $json_object= file_get_contents($url);
                $json_decoded = json_decode($json_object);

                foreach ($json_decoded->response->players as $player) {
                    $queryas = $db->prepare("SELECT * FROM users WHERE steamid=:steamid");
                    $queryas->bindParam("steamid", $player->steamid, PDO::PARAM_STR);
                    $queryas->execute();

                    if ($queryas->rowCount() > 0) {
                        $query = $db->prepare("UPDATE users SET name=:name, photo=:photo, profile=:profile, steamid=:steamid WHERE steamid=:steamid");
                        $query->bindParam("name", $player->personaname, PDO::PARAM_STR);
                        $query->bindParam("photo", $player->avatar, PDO::PARAM_STR);
                        $query->bindParam("profile", $player->profileurl, PDO::PARAM_STR);
                        $query->bindParam("steamid", $player->steamid, PDO::PARAM_STR);
                        $query->execute();
                    } else {
                        $query = $db->prepare("INSERT INTO users(name, photo, profile, steamid, balance, email) VALUES (:name, :photo, :profile, :steamid, 0, -)"); // Pridėti vis naujas nulines reikšmes.
                        $query->bindParam("name", $player->personaname, PDO::PARAM_STR);
                        $query->bindParam("photo", $player->avatar, PDO::PARAM_STR);
                        $query->bindParam("profile", $player->profileurl, PDO::PARAM_STR);
                        $query->bindParam("steamid", $player->steamid, PDO::PARAM_STR);
                        $query->execute();
                    }
                }

                if (!headers_sent()) {
                    header('Location: '.$steamauth['loginpage']);
                    exit;
                } else {
                    ?>
                    <script type="text/javascript">
                        window.location.href="<?=$steamauth['loginpage']?>";
                    </script>
                    <noscript>
                        <meta http-equiv="refresh" content="0;url=<?=$steamauth['loginpage']?>" />
                    </noscript>
                    <?php
                    exit;
                }
            } else {
                echo "User is not logged in.\n";
            }
        }
    } catch(ErrorException $e) {
        echo $e->getMessage();
    }
}

0 个答案:

没有答案