Skip to content

mukunda-/steamidparser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SteamID Parser

This is a simple library for PHP, JavaScript, and C++ to parse and format Steam IDs.

Compatible with 32-bit PHP builds.

PHP usage example:

require_once 'lib/steamid.php';

// parse a Steam ID in "SteamID3" format.
$steamid = SteamID::Parse( 
        "[U:1:108998443]", SteamID::FORMAT_STEAMID3 );

// print it in SteamID32 format
echo $steamid->Format( SteamID::FORMAT_STEAMID32 );

// (prints "STEAM_1:1:54499221")

JavaScript usage example (after referencing the library):

// parse a Steam ID in "SteamID3" format.
var steamid = SteamID.Parse( 
        "[U:1:108998443]", SteamID.Format.STEAMID3 );

// print it in SteamID32 format
console.log( steamid.Format( SteamID.Format.STEAMID32 ) );

// (prints "STEAM_1:1:54499221")

C++ usage example:

#include <steamid.hpp>
...

// parse a Steam ID in "SteamID3" format.
SteamID steamid( "[U:1:108998443]", SteamID::Formats::STEAMID3 );

// print it in SteamID32 format
std::cout << steamid[ SteamID::Formats::STEAMID32 ];

// (prints "STEAM_1:1:54499221")

Supports multiple formats. You can omit the parsing format for auto-detection.

The PHP version also supports Vanity URL (Custom URL) conversion. For optimal performance, you need to set a SteamAPIKey to use.

require_once 'lib/steamid.php';

// Optional: set Steam API Key
SteamID::SetSteamAPIKey( ... );

// parse directly as a Vanity URL
$steamid = SteamID::Parse( "prayspray", SteamID::FORMAT_VANITY );

// detect a vanity URL and parse it (note parameter 3 must be set)
$steamid = SteamID::Parse( "prayspray", SteamID::FORMAT_AUTO, true );

// print it in SteamID3 format
echo $steamid->Format( SteamID::FORMAT_STEAMID3 );

// (prints "[U:1:108998443]")

Get a Steam API key from http://steamcommunity.com/dev/apikey

If you don't set a Steam API key, the program will fall back to requesting the user profile as XML and parsing the Steam ID from there. (which is much less optimal.)

Formats supported by auto detection:

About

Steam ID parsing/formatting API for PHP, JavaScript, and C++

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published