Steam オープン ID を使用して、ユーザーが自分の Web サイトにログインできるようにしています。これが私が今持っているものです。チュートリアルからこれを取得し、ニーズに合わせて変更しただけではありません。
<?php
include "apikey.php";
include "OpenID.php";
$link = mysql_connect('', '', '', ' ');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
$OpenID = new LightOpenID("MyWebsite");
session_start();
if(!$OpenID->mode) {
if(isset($_GET['login'])) {
$OpenID->identity = "http://steamcommunity.com/openid";
header("Location: {$OpenID->authUrl()}");
}
if(!isset($_SESSION['T2SteamAuth'])){
$login = print ('<form action="?login" method="post">
<input type="image" src="http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_large_border.png"/>
</form>');
}
} elseif($OpenID->mode == "cancel") {
echo "canceled";
} 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: login3.php");
}
}
if(isset($_SESSION['T2SteamAuth'])) {
$Steam64id = $_SESSION['T2SteamAuth'];
print($Steam64id);
$sql = "INSERT INTO ``.`` (`id`) VALUES ('$Steam64id')";
mysql_query($sql, $link);
mysql_close($link);
print('<form action = "?logout" method="post"><button title="logout" name="logout">Logout</button></form>');
}
if(isset($_GET['logout'])) {
unset($_SESSION['T2SteamAuth']);
unset($_SESSION['T2SteamID64']);
header("Location: login3.php");
}
?>
このコードにより、ユーザーは自分のサイトにログインできるようになり、ユーザーの ID がデータベースに送信されます。私がやりたいことは、これらのユーザーがフォーラムを使用できるようにすることです。フォーラム プラグインとオープン ID をダウンロードしましたが、なんらかの理由でコードが原因でユーザーがフォーラムを使用できず、その理由がわかりません。ユーザーに私のフォーラムを使用してもらうには、wp-login.php にアクセスしてhttps://steamcommunity.com/openid/loginと入力し、私のコードとは別にその方法でログインする必要があります。このコードを使用して、ユーザーがフォーラムにログインできるようにしたいと考えています。どんな助けでも素晴らしいでしょう。ありがとう