PHP code example of xpaw / steamid
1. Go to this page and download the library: Download xpaw/steamid 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/ */
xpaw / steamid example snippets
use xPaw\Steam\SteamID;
try
{
// Constructor also accepts Steam3 and Steam2 representations
$s = new SteamID( '76561197984981409' );
}
catch( InvalidArgumentException $e )
{
echo 'Given SteamID could not be parsed.';
}
// Renders SteamID in it's Steam3 representation (e.g. [U:1:24715681])
echo $s->RenderSteam3() . PHP_EOL;
// Renders SteamID in it's Steam2 representation (e.g. STEAM_0:1:12357840)
echo $s->RenderSteam2() . PHP_EOL;
// Converts this SteamID into it's 64bit integer form (e.g. 76561197984981409)
echo $s->ConvertToUInt64() . PHP_EOL;
use xPaw\Steam\SteamID;
try
{
$s = new SteamID( $ID );
if( $s->GetAccountType() !== SteamID::TypeIndividual )
{
throw new InvalidArgumentException( 'We only support individual SteamIDs.' );
}
else if( !$s->IsValid() )
{
throw new InvalidArgumentException( 'Invalid SteamID.' );
}
$s->SetAccountInstance( SteamID::DesktopInstance );
$s->SetAccountUniverse( SteamID::UniversePublic );
var_dump( $s->RenderSteam3() ); // [U:1:24715681]
var_dump( $s->ConvertToUInt64() ); // 76561197984981409
}
catch( InvalidArgumentException $e )
{
echo $e->getMessage();
}