Steam-OpenID-PHP和HTML

Steam-OpenID-PHP和HTML,php,openid,steam-web-api,Php,Openid,Steam Web Api,所以我也在尝试为我的站点制作一个steam登录按钮,但它并没有重定向到我想要的WARE。相反,它只是将用户引导到一个带有用户名和注销按钮的普通站点。我没有写这段代码,我只是复制了别人的代码来尝试。我试图将它引导回index.php,但它不想太多。 代码如下: <?php error_reporting(E_ERROR | E_PARSE | E_WARNING); $user = new user; $user->apikey = "

所以我也在尝试为我的站点制作一个steam登录按钮,但它并没有重定向到我想要的WARE。相反,它只是将用户引导到一个带有用户名和注销按钮的普通站点。我没有写这段代码,我只是复制了别人的代码来尝试。我试图将它引导回index.php,但它不想太多。 代码如下:

<?php
                        error_reporting(E_ERROR | E_PARSE | E_WARNING);

$user = new user;
$user->apikey = ""; // put your API key here
$user->domain = "localhost/index.php"; // put your domain


class user
{
    public static $apikey;
    public static $domain;

    public function GetPlayerSummaries ($steamid)
    {
        $response = file_get_contents('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' . $this->apikey . '&steamids=' . $steamid);
        $json = json_decode($response);
        return $json->response->players[0];
    }

    public function signIn ()
    {
        require_once 'openid.php';
        $openid = new LightOpenID($this->domain);// put your domain
        if(!$openid->mode)
        {
            $openid->identity = 'http://steamcommunity.com/openid';
            header('Location: ' . $openid->authUrl());
        }
        elseif($openid->mode == 'cancel')
        {
            print ('User has canceled authentication!');
        }
        else
        {
            if($openid->validate())
            {
                preg_match("/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/", $openid->identity, $matches); // steamID: $matches[1]
                setcookie('steamID', $matches[1], time()+(60*60*24*7), '/'); // 1 week
                header('Location: /');
                exit;
            }
            else
            {
                print ('fail');
            }
        }
    }
}

if(isset($_GET['login']))
{
    $user->signIn();
}
if (array_key_exists( 'logout', $_POST ))
{
    setcookie('steamID', '', -1, '/');
    header('Location: /');
}


if(!$_COOKIE['steamID'])
{
    print ('<form action="?login" method="post">
        <input type="image" src="http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_large_border.png"/>
        </form>');
}
else
{
    print('<form method="post"><button title="Logout" name="logout">Logout</button></form>');
    echo $user->GetPlayerSummaries($_COOKIE['steamID'])->personaname;
}




?>

我对我的steam网站使用相同的代码

在这方面的代码,应该有一个修复。 我似乎找不到我的php,因为我用2个php链接和使用框架将它们与一个或另一个链接连接起来,使我的php变得非常复杂

正如你所说的

{
print('<form method="post"><button title="Logout" name="logout">Logout</button></form>');
echo $user->GetPlayerSummaries($_COOKIE['steamID'])->personaname; 
}
{
打印(“注销”);
echo$user->GetPlayerSummaries($_COOKIE['streamid'])->PersonalName;
}
我的是这样做的,用这个php代码加载了login/logout按钮。我不确定这是否对你有帮助! 如果使用此代码,请确保为登录网站启用了
allow\u url\u fopen

$sign\u inout=file\u get\u contents(“”)

echo$sign\u inout

感谢您花时间阅读此文章

{
print('<form method="post"><button title="Logout" name="logout">Logout</button></form>');
echo $user->GetPlayerSummaries($_COOKIE['steamID'])->personaname; 
}