0
目前正在使用Shoutbox並使用LightOpenID提供Steam登錄方法。我也在使用Yii2框架。任何幫助將不勝感激!提前致謝。lightopenid不會發佈會話變量
下面是index.php,它根據SteamID發佈數據。
<?php
/* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $model app\models\LoginForm */
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
$this->title = 'Dashboard';
$this->params['breadcrumbs'][] = $this->title;
require "steamauth/steamauth.php";
if(!isset($_SESSION['steamid'])) {
echo('Hitting no steamid marker');
$localUserName = "Guest";
} else {
include ('steamauth/userInfo.php');
$localUserName = ucfirst($_SESSION['steam_personaname']);
};
if (!isset($_SESSION['steamid'])) {
echo ("<div class='well'>
<div class='jumbotron'>
<h1>Login here.</h1>
<p>This prevents x from having to store user passwords. Powered by <a href='http://www.steampowered.com'><strong>STEAM</strong></a>.</p>
<p><a id='steamlogin' href='?r=user-record/index&login=1' class='btn btn-success btn-large loginButton'><span class='glyphicon glyphicon-log-in'></span> Login through Steam</a></p>
</div>
</div>");
$this->title = 'Login';
} else {
echo("
<div class='well'>
<div class='jumbotron'>
<h1>Dashboard</h1>
<p>Hey there, <a href=". $_SESSION['steam_profileurl'] . "><strong>" . $_SESSION['steam_personaname'] . "</strong></a>. </p>
<p><img src=" . $_SESSION['steam_avatarfull'] . "</img></p>
<p>Steam ID: <strong>" . $_SESSION['steamid'] . "</strong></p>
<p>
<p><a id='steamlogout' href='?r=user-record/index&logout=1' class='btn btn-danger btn-large logoutButton'><span class='glyphicon glyphicon-log-out'></span> Disconnect</a></p>
</div>
</div>");
}
?>
這是授權文件,這使它一路返回authURL但然後繼續回到登錄頁面重定向不設置任何變量。期待它返回「蒸汽」。
ob_start();
if (isset($_GET['login'])){
require 'openid.php';
echo('login initiated');
try {
echo('try initiiated');
require 'SteamConfig.php';
$openid = new LightOpenID($steamauth['domainname']);
if(!$openid->mode) {
$openid->identity = 'http://steamcommunity.com/openid';
return Yii::$app->getResponse()->redirect($openid->authUrl());
} elseif ($openid->mode == 'cancel') {
echo 'User has canceled authentication!';
} else {
if($openid->validate()) {
echo("reached validation");
$id = $openid->identity;
$ptn = '/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/';
preg_match($ptn, $id, $matches);
$_SESSION['steamid'] = $matches[1];
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();
}
}
什麼時候開始使用他們的所有文件裏面的會議? –
就這麼簡單。哇。謝謝。 –
不客氣。如果您希望將其標記爲已解決,我會在那裏爲您彈出一個答案 –