1. Go to this page and download the library: Download jacobfitz/steamauth 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/ */
jacobfitz / steamauth example snippets
$request = new \SteamAuth\Request('API_KEY', 'RETURN_URL');
/* Option 1: Redirect the user */
$request->redirectToLogin();
/* Option 2: Present the user with a link or login button */
echo '<a href="' . $request->getLoginURL() . '">Login with Steam</a>';
$response = new \SteamAuth\Response('API_KEY');
/* Check if the response is valid */
if ($response->isValid()) {
/**
* At this point the user is now logged in.
* Their data will automatically be saved to the session.
*/
/* Get the steam user */
$user = $response->getUser();
} else {
/* Get errors */
$errors = $response->getErrors();
}
if (\SteamAuth\User::isLoggedIn()) {
doSomeStuff();
}
$user = \SteamAuth\User::getCurrent();
$user->reload();
/* Directly access an attribute, see ATTRIBUTE_* constants for options */
$user->getAttribute($user::ATTRIBUTE_USERNAME);
// --------------- Steam ID ---------------
$user->getSteamID();
// --------------- Username ---------------
$user->getUsername();
// --------------- Avatar ---------------
$user->getAvatar();
/* Specify size */
$user->getAvatar($user::AVATAR_SIZE_MEDIUM);
// --------------- Status ---------------
$user->getStatus();
/* Check status */
if ($user->checkStatus($user::STATE_ONLINE)) {
doSomeStuff();
}
// --------------- Real Name ---------------
/* This isn't always visible, check is is first */
if ($user->hasRealName()) {
/* Get real name */
$user->getRealName();
}
// --------------- Profile URL ---------------
$user->getURL();
// --------------- Community Profile ---------------
$user->isCommunityProfile();
// --------------- Time ---------------
/* Get account creation time */
$user->getTimeCreated();
/* Get last logoff time */
$user->getLastLogOffTime();
// --------------- Visibility ---------------
$user->getVisibility();
/* Check visibility */
if ($user->checkVisibility($user::VISIBILITY_PUBLIC)) {
doSomeStuff();
}
// --------------- Logout ---------------
\SteamAuth\User::logout();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.