Coder Social home page Coder Social logo

zipcore / steamidparser Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mukunda-/steamidparser

0.0 2.0 0.0 211 KB

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

License: Other

C++ 34.82% JavaScript 24.81% PHP 40.02% HTML 0.34%

steamidparser's Introduction

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:

steamidparser's People

Contributors

mukunda- avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.