Raised This Month: $ Target: $400
 0% 

Convert STEAMID to Steam Community ID


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
4ever16
Veteran Member
Join Date: Apr 2015
Old 03-12-2020 , 07:19   Re: Convert STEAMID to Steam Community ID
Reply With Quote #11

Quote:
Originally Posted by DarthNinja View Post
Here's some php I wrote to calculate Steam Community IDs using php's basic math functions.
(No php extensions required )


PHP Code:
//Get SteamID and save it to $steam_id somehow

<?php
$steam_id
=strtolower($steamid);
if (
substr($steam_id,0,7)=='steam_0') {
$tmp=explode(':',$steam_id);
}
if ((
count($tmp)==3) && is_numeric($tmp[1]) && is_numeric($tmp[2])){
 
 
//The 'Magic Number': 76561197960265728
 //Split up so it can be calculated without an extension.
 

 
$steamidCalc=($tmp[2]*2)+$tmp[1]; //Work out step 1
$calckey='1197960265728'//Second bit of the magic number
$pre='7656'//First bit of the magic number
    
$steamcid=$steamidCalc+$calckey//works out the ending of the steam community ID
    
$link="http://steamcommunity.com/profiles/";
echo 
$link; echo $pre; echo $steamcid;
 
 };

?>
By breaking off a few digit, it prevents php from outputting the number using scientific notation.
This does however, mean that this will have to be updated once there are enough steam accounts to make the numbers roll over.

Hope that's helpful to someone
Thanks!
4ever16 is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:24.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode