Skip to content
PHP tool to fetch static data from the Steam User profile page based on Steam Custom ID
PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ISSUE_TEMPLATE.md
LICENSE
PersistenceDB.php
README.md
SteamProfileReader.php
config.php
example.php

README.md

SteamProfileReader

This PHP class provides a tool to fetch static data from the Steam User profile page based on a provided Steam Custom ID

Requirements

  • PHP 5.6 or greater
  • MySql database ( optional )

Installation

  1. Copy or clone the reporitory
  2. Place the SteamProfileReader.php, PersistenceDB.php and config.php in the same folder
  3. Include the SteamProfileReader.php inside a dedicated page or in any place of your code
  4. Change the setting into the config.php to match your installation

Steam Custom ID

The Steam Custom ID differs from the SteamID . The Steam Custom ID refers to the ID used by Steam to identify an user profile page : http://steamcommunity.com/id/<steamCustomId> This ID could be totally different from the Steam ID and it's choosen by the user itself from the profile editor page

Profile Editor

Run the tool

  1. Create a new instance of the SteamProfileReader : $spr = new SteamProfileReader('<Steam Custom ID>');
  2. Fetch content live or save it into your database

Data and information

All data coming from this class it is publicly accessible. We do not :

  • use any illegal action to fetch them
  • interfere with service or security service of the website
  • steal this data from any protected section of the website

Any type of abuse it's reasonable on a wrong usage of the component or modification by the original code and purpose

Live fetching

When using the live fetch, the tool read the Steam page profile based on the Steam Custom ID provided into the constructor, and retrive the content from the page. Using different methods it's possible to obtain specific part of the user profile :

  1. $steamProfileReader->getFavGame() - retrive an object that containts the favorite game selected displayed on the user profile Structure of the FavGame object :
            $game->img  	   : Favourite game image url to Steam page
            $game->link 	   : Favourite game url to the Steam page
            $game->name 	   : Favourite game name
            $game->time 	   : Favourite hours played
            $game->achivNumber : Favourite number of achievements
  1. $steamProfileReader->getFeaturedGames() - retrive an array of objects containing the featured games displayed on the user profile Structure of the FeaturedGame object :
            $game->name       : Game name
            $game->page       : Game url to Steam page            
            $game->img        : Game image url
  1. $steamProfileReader->getMedals() - retrive an array of objects containing the displayed medals on the user profile Structure of the Medal object :
            $medal->name  : Medal name 
            $medal->link  : Medal url to Steam page
            $medal->img   : Medal image url to Steam page
  1. $steamProfileReader->getAchivements() - retrive an array of objects containing the displayed achievements on the user profile Structure of the Achievement object :
            $achievement->game        : Game name
            $achievement->name        : Achievement name
            $achievement->description : Achievement description
            $achievement->page        : Achievement url to Steam page
            $achievement->img         : Achievement image url to Steam page
  1. $steamProfileReader->getUserDetails() - retrive an objects containing the user profile details Structure of the User object :
            $user->nickname  : User steam nickname
            $user->imgFull   : User image url to Steam page ( large format )
            $user->imgMid    : User image url to Steam page ( medium format )
            $user->imgSmall  : User image url to Steam page ( small format )
            $user->level     : User Steam level
            $user->badgeName : User profile badge name
            $user->badgePage : Badge profile url to Steam page
            $user->badgeImg  : Badge profile image url to Steam page

Persistence on DB

Is it possible to directly store all the previous information ( array and object ) into a predefined set of tables. To realize it :

$steamProfileReader = new SteamProfileReader('<Steam Custom ID>');
$steamProfileReader->saveOnDb();

The function takes care of all the necessary steps to be able to store all the structure and the related information. Prior this, you have to define your system setting to be able to communicate with the database inside the config.php file :

  1. Choose your prefix name for the tables : define(TABLEPREFIX,<prefix_name>)

  2. Six tables are created using the prefix name string : PREFIX_achievements, PREFIX_conf, PREFIX_favgames, PREFIX_medals, PREFIX_playedGames, PREFIX_users

  3. Running the function will fetch the data from the Steam profile page and store it in the related table. Each element of the table it's stored using as ID an MD5 values of the full set of information to avoid storing the same type of object more than once.

    Tables follows this structure :

		//Conf table
		`id` varchar(255) NOT NULL,
		`Name` varchar(255) CHARACTER SET utf8 NOT NULL,
		`Value` varchar(255) CHARACTER SET utf8 NOT NULL,
		PRIMARY KEY , UNIQUE (id)

		//Users table
		`id` varchar(255) NOT NULL,
		`steamID` varchar(255) CHARACTER SET utf8 NOT NULL,
		`nickname` varchar(255) CHARACTER SET utf8 NOT NULL,
		`imgFull` varchar(255) CHARACTER SET utf8 NOT NULL,
		`imgMid` varchar(255) CHARACTER SET utf8 NOT NULL,
		`imgSmall` varchar(255) CHARACTER SET utf8 NOT NULL,
		`level` varchar(255) CHARACTER SET utf8 NOT NULL,
		`badgeName` varchar(255) CHARACTER SET utf8 NOT NULL,
		`badgePage` varchar(255) CHARACTER SET utf8 NOT NULL,
		`badgeImg` varchar(255) CHARACTER SET utf8 NOT NULL,                
		PRIMARY KEY UNIQUE (id)              

		//Favgames table
		`id` varchar(255) NOT NULL,
		`steamID` varchar(255) CHARACTER SET utf8 NOT NULL,
		`img` varchar(255) CHARACTER SET utf8 NOT NULL,
		`link` varchar(255) CHARACTER SET utf8 NOT NULL,
		`name` varchar(255) CHARACTER SET utf8 NOT NULL,
		`time` varchar(255) CHARACTER SET utf8 NOT NULL,
		`achivNumber` varchar(255) CHARACTER SET utf8 NOT NULL,
		PRIMARY KEY UNIQUE (id)              

        // Featured table
        `name` varchar(255) CHARACTER SET utf8 NULL,
        `url` varchar(255) CHARACTER SET utf8 NOT NULL,
        `image` varchar(255) CHARACTER SET utf8 NOT NULL,
        PRIMARY KEY UNIQUE (name)

		// Achievement table
		`id` varchar(255) NOT NULL,
		`steamID` varchar(255) CHARACTER SET utf8 NOT NULL,               
		`game` varchar(255) CHARACTER SET utf8 NOT NULL,
		`name` varchar(255) CHARACTER SET utf8 NOT NULL,
		`description` varchar(255) CHARACTER SET utf8 NOT NULL,
		`page` varchar(255) CHARACTER SET utf8 NOT NULL,
		`img` varchar(255) CHARACTER SET utf8 NOT NULL,
		PRIMARY KEY UNIQUE (id)              

		// Medals table
		`id` varchar(255) NOT NULL,
		`steamID` varchar(255) CHARACTER SET utf8 NOT NULL,
		`name` varchar(255) CHARACTER SET utf8 NOT NULL,              
		`link` varchar(255) CHARACTER SET utf8 NOT NULL,
		`img` varchar(255) CHARACTER SET utf8 NOT NULL,                            
		PRIMARY KEY UNIQUE (id)              

Check User status

SteamProfileReader::checkUserStatus(<Steam Custom ID>); It is possible to receive the online status for a user, using the Steam Custom ID, calling the static method checkUserStatus. This will return his online status (Currently Online/Currently Offline) always based on the information provided by the Steam user page

DISCLAIMER

All contents fetched,loaded,read from Steam are protected by copyright and trademarks by Steam, the software owner and/or third party license . Please check Legal, Privacy Policy, User Agreement for further information

I'm not responsible for any issue nor any kind of legal affair that this component could or would cause at your person/business.

You can’t perform that action at this time.