• Problem with login via Steam openid (Lightopenid)
    2 replies, posted
I started work on the site for the game server, and want to do authorization via Steam, I did everything [URL="http://nikey.me/127/steam-open-id-tutorial-php-video"]tutorial[/URL], but nothing works. Problem in this line: $_SESSION['T2SteamAuth'] = $OpenID->validate() ? $OpenID->identity : null; For some reason I can not get the validation Code: [PHP] include "api.php"; // My api key include "openid.php"; //Official light open id lib. $OpenID = new LightOpenID("somesiteplease.p.ht"); session_start(); if(!$OpenID->mode){ if(isset($_GET['login'])){ $OpenID->identity = "http://steamcommunity.com/openid"; header("Location: {$OpenID->authUrl()}"); } if(!isset($_SESSION['T2SteamAuth'])){ echo "<a href=\"?login\"><img src=\"http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_small.png\" border=\"0\"/></a>"; } } elseif($OpenID->mode == "cancel"){ echo "User has canceled Authenticiation."; } else { if(!isset($_SESSION['T2SteamAuth'])){ $_SESSION['T2SteamAuth'] = $OpenID->validate() ? $OpenID->identity : null; $_SESSION['T2SteamID64'] = str_replace("http://steamcommunity.com/openid/id/", "", $_SESSION['T2SteamAuth']); if($_SESSION['T2SteamAuth'] !== null){ $Steam64 = str_replace("http://steamcommunity.com/openid/id/", "", $_SESSION['T2SteamAuth']); $profile = file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key={$api}&steamids={$Steam64}"); $buffer = fopen("cache/{$Steam64}.json", "w+"); fwrite($buffer, $profile); fclose($buffer); } header("Location: index.php"); } } if(isset($_SESSION['T2SteamAuth'])){ echo "<div id=\"login\"><a href=\"?logout\">Logout</a></div>"; $steam = json_decode(file_get_contents("cache/{$_SESSION['T2SteamID64']}.json")); echo "<img src=\"{$steam->response->players[0]->avatarfull}\"/>"; } if(isset($_GET['logout'])){ unset($_SESSION['T2SteamAuth']); unset($_SESSION['T2SteamID64']); header("Location: index.php"); } [/PHP] P.S. sorry for my english.
Here is what I use for reference: in the index page of the website: [code]if(isset($_GET['steam_login'])) { require ('openid_integration/openid.php'); try { # Change 'localhost' to your domain name. $openid = new LightOpenID('domain'); if(!$openid->mode) { if(isset($_GET['st-login'])) { $openid->identity = 'http://steamcommunity.com/openid'; header('Location: ' . $openid->authUrl()); } } elseif($openid->mode == 'cancel') { echo 'User has canceled authentication!'; } else { if($openid->validate()) { $id = $openid->identity; // identity is something like: http://steamcommunity.com/openid/id/76561197994761333 // we only care about the unique account ID at the end of the URL. $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/"; preg_match($ptn, $id, $matches); $steaminfo['64id'] = $matches[1]; //64 bit raw id sent from Steam $authserver = bcsub($steaminfo['64id'], '76561197960265728') & 1; //Converting the 64bit id toa STEAM_0 e.t.c ID. $authid = (bcsub($steaminfo['64id'], '76561197960265728')-$authserver)/2; $steaminfo['steamid'] = "STEAM_0:$authserver:$authid"; } else { $steamerror = "A problem occured with the Steam sign-in process, please try again."; } } } catch(ErrorException $e) { echo $e->getMessage(); } }[/code] Then when I need to call a request I just send a form with a get variable. It's pretty standard, just included algorithm to convert 64bit community ID to Steam ID.
Does not work :( openid->validate () returns false
Sorry, you need to Log In to post a reply to this thread.