Raised This Month: $ Target: $400
 0% 

Convert STEAMID to Steam Community ID


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nican
Veteran Member
Join Date: Jan 2006
Location: NY
Old 02-04-2008 , 22:23   Re: Convert STEAMID to Steam Community ID
Reply With Quote #1

76561197985873864

If you go over the "Add to your friends list", and check the link, you will see his friends id
__________________
http://www.nican132.com
I require reputation!
Nican is offline
Send a message via ICQ to Nican Send a message via MSN to Nican
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 02-05-2008 , 10:46   Re: Convert STEAMID to Steam Community ID
Reply With Quote #2

Very nicely done! Thanks for sharing too. +karma
bl4nk is offline
Jheshka
Senior Member
Join Date: Dec 2005
Old 02-08-2008 , 19:12   Re: Convert STEAMID to Steam Community ID
Reply With Quote #3

Wow... Very nice.
__________________
James
Jheshka is offline
mindstormmaster
New Member
Join Date: Feb 2008
Old 02-13-2008 , 14:02   Re: Convert STEAMID to Steam Community ID
Reply With Quote #4

It looks like there's some code missing. What you have there doesn't store anything back to Memcached, making it irrelevant in this example. Your comments are great, but could you post the complete script?
mindstormmaster is offline
KoST
Senior Member
Join Date: Jul 2005
Old 02-13-2008 , 19:58   Re: Convert STEAMID to Steam Community ID
Reply With Quote #5

Quote:
Originally Posted by mindstormmaster View Post
It looks like there's some code missing. What you have there doesn't store anything back to Memcached, making it irrelevant in this example. Your comments are great, but could you post the complete script?
here is my original code:
PHP Code:
<?php
 
function get_steam_stats($id){
    
    
$mc=new Memcache;
    if (!
$mc->connect('localhost'11211)) return false;
    
    
$ret=$mc->get('xd'.$id);
    if (!
$ret){
        
$data=file_get_contents("http://steamcommunity.com/profiles/".$id);    
        
$ret=array();
        
        
        
        if (
strpos($data,'<h2>Private Profile</h2>')!==false) {
            
$ret['private']=1;
        }else{
            if (
strpos($data,'status_online.gif')!==false){
                
$ret['online']=1;
            }else if ((
$p1=strpos($data,'<p id="statusInGameText">'))!==false){
                
                
$p2=strpos($data,'<',$p1+25);
                
$tmp=substr($data,$p1+25,$p2-$p1-25);
                
$ret['ingame']=$tmp;
                
$ret['join']='steam://friends/joingame/'.$id;
 
                
            }else{ 
                if ((
$p1=strpos($data,'<p id="statusOfflineText">'))!==false){
                    
$p2=strpos($data,'<',$p1+26);
                    
$tmp=substr($data,$p1+26,$p2-$p1-26);
                    
$ret['offline']=$tmp;
                }
            }
            
            if ((
$p1=strpos($data,'<div class="avatarFull">'))!==false){
                
$p1=strpos($data,'<',$p1+24);
                
$p2=strpos($data,'>',$p1+1);
                
$tmp=substr($data,$p1,$p2-$p1+1);
                
$link_full=get_link_src($tmp);
                
gaben_downloadz0r($link_full,'/home/lol/public_html/avatars/lol_full'.$id.'.jpg');
                
$ret['img_full']=$tmp;
                
                
$tmp=str_replace('_full','',$tmp);
                
$link_small=get_link_src($tmp);
                
gaben_downloadz0r($link_small,'/home/lol/public_html/avatars/lol_small'.$id.'.jpg');
                
$ret['img_small']=$tmp;
            }
                
            if ((
$p1=strpos($data,'Steam Rating:</div>'))!==false){
                
$p2=strpos($data,'<',$p1+19);
                
$tmp=substr($data,$p1+19,$p2-$p1-19);
                
$ret['rating']=trim($tmp);
            }    
            
            if ((
$p1=strpos($data,'Member since:</div>'))!==false){
                
$p2=strpos($data,'<',$p1+19);
                
$tmp=substr($data,$p1+19,$p2-$p1-19);
                
$ret['member']=trim($tmp);
            }
            
            if ((
$p1=strpos($data,'Playing time:</div>'))!==false){
                
$p2=strpos($data,'<',$p1+19);
                
$tmp=substr($data,$p1+19,$p2-$p1-19);
                
$ret['time']=trim($tmp);
            }
            
        }
        
$mc->set('xd'.$id,$ret,MEMCACHE_COMPRESSED,1800);        
        
        
        
    }
    
    
 
    return 
$ret;
        
}
 
 
function 
get_link_src($data){
    
$p1=strpos($data,chr(34));
    
$p2=strpos($data,chr(34),$p1+1);
    return 
substr($data,$p1+1,$p2-$p1-1);
}
 
function 
gaben_downloadz0r ($url,$target){    
    
$data=file_get_contents($url);
    if (
$data) {
        
file_put_contents($target,$data);    
    }
}
?>
__________________

Last edited by KoST; 02-13-2008 at 20:01.
KoST is offline
8088
Veteran Member
Join Date: Jan 2008
Old 02-14-2008 , 18:58   Re: Convert STEAMID to Steam Community ID
Reply With Quote #6

Quote:
Originally Posted by mindstormmaster View Post
It looks like there's some code missing.
Oops, my bad. Thanks for clearing it up, KoST.
8088 is offline
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 02-14-2008 , 13:25   Re: Convert STEAMID to Steam Community ID
Reply With Quote #7

This is awsome +karma for sure!
Styles is offline
Send a message via AIM to Styles
S1acker
Junior Member
Join Date: Aug 2007
Old 03-09-2008 , 05:51   Re: Convert STEAMID to Steam Community ID
Reply With Quote #8

ty
S1acker is offline
Rick87
New Member
Join Date: Mar 2008
Old 03-11-2008 , 13:52   Re: Convert STEAMID to Steam Community ID
Reply With Quote #9

I've tracked down the error. The steam2friend function isn't giving any output, or even an error. I tried manually forcing the variable to be my friendid as a test, but then PHP shifts it into exponential format and things go awry. I feel like such a noob right now! Many thanks for your help.
Rick87 is offline
8088
Veteran Member
Join Date: Jan 2008
Old 03-11-2008 , 20:41   Re: Convert STEAMID to Steam Community ID
Reply With Quote #10

My offer to contact me through Steam still stands ;)
8088 is offline
Reply



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 00:25.


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