1. Go to this page and download the library: Download kanalumaddela/steam-login library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kanalumaddela / steam-login example snippets
analumaddela\SteamLogin\SteamLogin;
// init instance
$steamlogin = new SteamLogin();
// redirect to steam
if ($_SERVER['QUERY_STRING'] == 'login') {
$steamlogin->login();
}
// logout
if ($_SERVER['QUERY_STRING'] == 'logout') {
$steamlogin->logout();
}
if (SteamLogin::validRequest()) {
$player = $steamlogin->getPlayerInfo();
echo '<pre>';
print_r($player);
echo '</pre>';
} else {
echo '<a href="?login">'.SteamLogin::button('large', true).'</a>';
}
analumaddela\SteamLogin\SteamLogin;
$options = [
'method' => 'xml',
'api_key' => '',
'timeout' => 15,
'session' => [
'name' => 'My Site', // gets converted to snake case e.g. My Site -> My_Site
'lifetime' => 0,
'path' => str_replace(basename(__FILE__), '', $_SERVER['PHP_SELF']),
'secure' => isset($_SERVER["HTTPS"])
],
];
// init instance
$steamlogin = new SteamLogin($options);
// redirect to steam
if ($_SERVER['QUERY_STRING'] == 'login') {
$steamlogin->login();
}
// logout
if ($_SERVER['QUERY_STRING'] == 'logout') {
$steamlogin->logout();
}
// show login or user info
if (!isset($_SESSION['steamid'])) {
echo '<a href="?login">'.SteamLogin::button('large', true).'</a>';
} else {
echo '<a href="?logout">Logout</a>';
echo '<pre>';
print_r($_SESSION);
echo '</pre>';
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.