Steam登录Lightopenid

我为我的登录创建了一个index.php,用户可以使用Steam登录我的网站获取 像他们的名字,头像和蒸汽ID这样的信息我遇到的问题是数据没有发送到我的数据库我已经制作了一个包含所有正确细节的db.php文件,因为它没有存储在我的数据库中。 </ p>

  $ db = mysql_connect(“localhost”,“username”,“password”); 
$ db = mysql_select_db(“mydbname”);

echo“
&lt; br&gt; SmallAvatar:&lt; img src ='$ player-&gt; avatar'/&gt;
&lt; br /&gt;玩家ID:$ player-&gt; steamid
&lt; br />播放器名称:$ player-&gt; personaname
&lt; br /&gt;配置文件URL:$ player-&gt; profileurl
“;
$ sql_fetch_id =”SELECT * FROM users_steam WHERE steamid ='$ player - &gt; steamid'“;
$ query_id = mysqli_query($ db,$ sql_fetch_id);

$ _SESSION ['name'] = $ player-&gt; personaname;
$ _SESSION ['steamid'] = $ player-&gt; steamid;
$ _SESSION ['avatar'] = $ player-&gt; avatar;

if(mysqli_num_rows($ query_id)== 0){
$ sql_steam =“INSERT INTO users_steam( name,steamid,avatar)VALUES('$ player-&gt; personaname','$ player-&gt; steamid','$ player-&gt; avatar')“;
mysqli_query($ db,$ sql_st eam);
}
</ code> </ pre>
</ div>

展开原文

原文

I have created a index.php for my login with steam for user to use there steam login for my site to get information like their name, avatar, and steam id the problem i'm having is that the data isn't sending to my database I have made a db.php file with all the right details just it's not storing in my database.

$db = mysql_connect("localhost", "username", "password");
$db = mysql_select_db("mydbname");



echo "
                <br/>SmallAvatar: <img src='$player->avatar'/>
                <br/>Player ID: $player->steamid
                <br/>Player Name: $player->personaname
                <br/>Profile URL: $player->profileurl 
                ";
            $sql_fetch_id = "SELECT * FROM users_steam WHERE steamid = '$player->steamid'";
            $query_id = mysqli_query($db, $sql_fetch_id);

            $_SESSION['name'] = $player->personaname;
            $_SESSION['steamid'] = $player->steamid;
            $_SESSION['avatar'] = $player->avatar;

            if (mysqli_num_rows($query_id) == 0) {
                $sql_steam = "INSERT INTO users_steam (name, steamid, avatar) VALUES  ('$player->personaname', '$player->steamid', '$player->avatar')";
                mysqli_query($db, $sql_steam);
            }

douliao5467
douliao5467 抱歉试图弄清楚为什么它不会让我把我的代码放进去,我不得不删除你输入的正常内容。
接近 5 年之前 回复
duanqiao1926
duanqiao1926 把你的一些工作代码?
接近 5 年之前 回复

1个回答



试试这个:</ p>

  require'openid.php'; 

include_once (“db.php”);

$ _STEAMAPI =“”;

try {
$ openid = new LightOpenID('www.audiochat.xyz / index.php');
if(!$ openid-&gt;模式){
if(isset($ _ GET ['login'])){
$ openid-&gt; identity ='http://steamcommunity.com/openid/?l = english'; \ n header('Location:'。$ openid-&gt; authUrl());
} else {
echo“&lt; h2&gt; Connect to Steam&lt; / h2&gt;”;
echo“&lt; form action =' ?login'methation ='post'&gt;“;
echo”&lt; input type ='image'src ='http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_small.png'>“ ;
echo“&lt; / form&gt;”;
}
} elseif($ openid-&gt; mode =='cancel'){
echo'User已取消身份验证!';
}其他{\ n if($ openid-&gt; validate()){
$ id = $ openid-&gt; identity;
$ ptn =“/ ^ http:\ / \ / steamcommunity \ .com \ / openid \ / id \ /(7 0-9] {15,25} +)$ /“;
preg_match($ ptn,$ id,$ matches);

$ url =”http://api.steampowered.com/ISteamUser/GetPlayerSummaries / v0002 /?key = $ _ STEAMAPI&amp; steamids = $ matches [1]“;
$ json_object = file_get_contents($ url);
$ json_decoded = json_decodemysql_select_db($ json_object);

foreach($ json_decoded-&gt ;响应 - &gt;玩家为$玩家)
{
$ sql_fetch_id =“SELECT * FROM users_steam WHERE steamid = $ player-&gt; steamid”;
$ query_id = mysqli_query($ db,$ sql_fetch_id);

if(mysqli_num_rows($ query_id)== 0){
$ sql_steam =“INSERT INTO users_steam(name,steamid,avatar)VALUES('$ player-&gt; personaname','$ player-&gt; steamid', '$ player-&gt; avatar')“;
mysqli_query($ db,$ sql_steam);
}
}
}其他{
echo”用户未登录。
“;
}

}
} catch(ErrorException $ e){
e cho $ e-&gt; getMessage();
}
</ code> </ pre>
</ div>

展开原文

原文

Try this:

require 'openid.php';

include_once("db.php");

$_STEAMAPI = "";

try {
    $openid = new LightOpenID('www.audiochat.xyz/index.php');
    if(!$openid->mode) {
        if(isset($_GET['login'])) {
            $openid->identity = 'http://steamcommunity.com/openid/?l=english';
            header('Location: ' . $openid->authUrl());
        } else {
            echo "<h2>Connect to Steam</h2>";
            echo "<form action='?login' method='post'>";
            echo "<input type='image' src='http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_small.png'>";
            echo "</form>";
        }
    } elseif($openid->mode == 'cancel') {
        echo 'User has canceled authentication!';
    } else {
        if($openid->validate()) {
            $id = $openid->identity;
            $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
            preg_match($ptn, $id, $matches);

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

        foreach ($json_decoded->response->players as $player)
        {
                $sql_fetch_id = "SELECT * FROM users_steam WHERE steamid = $player->steamid";
                $query_id = mysqli_query($db, $sql_fetch_id);

                if (mysqli_num_rows($query_id) == 0) {
                    $sql_steam = "INSERT INTO users_steam (name, steamid, avatar) VALUES  ('$player->personaname', '$player->steamid', '$player->avatar')";
                    mysqli_query($db, $sql_steam);
                }
            }
        } else {
                        echo "User is not logged in.
";
        }
    }
} catch(ErrorException $e) {
    echo $e->getMessage();
}

dongyu8694
dongyu8694 是的我试过了,但它和我现在的一样。 除了我添加的3行代码都没有存储数据,我真的很沮丧,这已经工作了大约一个星期。
接近 5 年之前 回复
duanchendu69495
duanchendu69495 你试过吗,因为你在前一个剧本中有一些错误
接近 5 年之前 回复
duanjurong1347
duanjurong1347 是的,这是我现在的脚本,似乎没有工作,也许蒸汽用这个登录代码更新他们的网站。 我已经添加了
接近 5 年之前 回复
doumanju2533
doumanju2533 我希望这有效
接近 5 年之前 回复
duaedf6509
duaedf6509 谢谢尝试的人,它仍然有保存的问题我不知道什么是问题是视频只有3个月我看,代码适合他。
接近 5 年之前 回复
dongxing1412
dongxing1412 我已经更新了代码,你可以看一看,看看有什么问题吗?
接近 5 年之前 回复
dongmuyan5638
dongmuyan5638 感谢您尝试的人,这不是问题,我的代码中的所有内容都是正确的,它看起来就是这样。
接近 5 年之前 回复
dongle19863
dongle19863 看看第二个链接
接近 5 年之前 回复
douhezhan5348
douhezhan5348 您好,谢谢,它显示了网站上的信息,但如果我需要,仍然不会将数据存储在我的数据库中。
接近 5 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐