Getting Started
Sam edited this page Mar 8, 2018
·
9 revisions
composer require kanalumaddela/steam-login
or
Download the master and include SteamLogin.php
use kanalumaddela\SteamLogin\SteamLogin;
$steamlogin = new SteamLogin();
or
$steamlogin = new SteamLogin($options, $suppress);
- pass custom options and boolean to hide some exceptions
$options = [
'method' => 'xml', // method of retrieving user's info: api/xml
'api_key' => '', // api key, http://steamcommunity.com/dev/apikey
'timeout' => 15, // # of secs to timeout when validating
'session' => [
'name' => 'SteamLogin', // session_name() that gets converted to snake case e.g. My Site -> My_Site
'lifetime' => 0, // lifetime of the session, 0 means until browser is closed
'path' => str_replace(basename(__FILE__), '', $_SERVER['PHP_SELF']), // session cookie path
'secure' => isset($_SERVER["HTTPS"]) // use secure cookie, server must be HTTPS
],
];
$suppress = true; // hide some exceptions and use workarounds
property | description |
---|---|
SteamLogin::validRequest() |
static function to check if $_GET has all the required parameters can be used to check before outputting ->player
|
SteamLogin::button($type, $img) |
returns the image url or the <img> element for the sign in through steam button small - large -
|
$steamlogin->login() |
redirects the user to steam via header()
|
$steamlogin->logout() |
destroys the session and redirect users back |
$steamlogin->loginURL |
URL of the steam openid for the current request |
$steamlogin->getPlayerInfo() |
get array of player's info including steam profile info, not required if using sessions |
if you are using the session method, this info is already there, the keys are the same
$player = $steamlogin->getPlayerInfo();
Bolded - Available via XML method only
Italicized - Available via API method only
var | description | example |
---|---|---|
$player->steamid | 64 bit steamid | 76561198152390718 |
$player->steamid2 | 32 bit steamid | STEAM_0:0:96062495 |
$player->steamid3 | SteamID3 | [U:1:192124990] |
$player->name | name | kanalumaddela |
$player->realName | real name | Sam |
$player->playerState | status | Online/Offline |
$player->stateMessage | status message | Online/Offline Last Online/In Game Busy/Away/Snooze/Looking to <trade/play> |
$player->privacyState | profile privacy | Private Friendsonly |
$player->visibilityState | visibility state | <1/2/3> |
$player->avatarSmall | small avatar | avatar url cdn.akamai.steamstatic.com (http) steamcdn-a.akamaihd.net (https) |
$player->avatarMedium | medium avatar | ^ |
$player->avatarLarge | large avatar | ^ |
$player->joined | date of joining steam | January 1st, 2018 (format is consistent XML method) |