Steam profile XML

how to parse the steamcommunity profile xml in php?
at the time I have it that way:

[children] => Array
        (
            [0] => domelement Object
                (
                    [type] => 1
                    [tagname] => profile
                    [0] => 5
                    [1] => 47824184
                    [children] => Array
                        (
                            [0] => domtext Object
                                (
                                    [type] => 3
                                    [name] => #text
                                    [content] => 
	
                                    [0] => 6
                                    [1] => 47827496
                                )

                            [1] => domelement Object
                                (
                                    [type] => 1
                                    [tagname] => steamID64
                                    [0] => 7
                                    [1] => 47827568
                                    [children] => Array
                                        (
                                            [0] => domtext Object
                                                (
                                                    [type] => 3
                                                    [name] => #text
                                                    [content] => 76561197984082852
                                                    [0] => 8
                                                    [1] => 47827640
                                                )

                                        )

but this is kind of unpractical

I don’t know much about xml but if you figure this out, please share. :slight_smile:

not perfect, but at least it works:


function getSteamprofile($url, $return_all = 0)
{
    $parser = xml_parser_create();
    xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
    xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
    $xml = file_get_contents($url);
    xml_parse_into_struct($parser, $xml, $value);
    xml_parser_free($parser);


         if($value[12]['tag'] === "inGameInfo")
         {
             $contents['inGameInfo'][] = $value[13]['value'];
             $contents['inGameInfo'][] = $value[14]['value'];
             $contents['inGameInfo'][] = $value[15]['value'];
             $contents['inGameInfo'][] = $value[16]['value'];
             $contents['inGameInfo'][] = $value[17]['value'];
             unset($value[13]);
             unset($value[14]);
             unset($value[15]);
             unset($value[16]);
             unset($value[17]);
             $user['ingameinfo']['name'] = $contents['inGameInfo'][0];
             $user['ingameinfo']['link'] = $contents['inGameInfo'][1];
             $user['ingameinfo']['icon'] = $contents['inGameInfo'][2];
             $user['ingameinfo']['logo'] = $contents['inGameInfo'][3];
             $user['ingameinfo']['logo_s'] = $contents['inGameInfo'][4];
         }
         else
         {
         }

    foreach( $value as $values )
    {
             $contents[$values['tag']][] = $values['value'];
    }
         unset($contents['inGameInfo'][5]);
         unset($contents['inGameInfo'][6]);


    $user['name'] = $contents['steamID'][0];
    $user['state'] = $contents['onlineState'][0];
    $user['msg'] = $contents['stateMessage'][0];
    $user['avatar'] = $contents['avatarFull'][0];
    $user['avatar_med'] = $contents['avatarMedium'][0];
    $user['avatar_ico'] = $contents['avatarIcon'][0];
    $user['vac'] = $contents['vacBanned'][0];
    $user['url'] = $contents['customURL'][0];
    $user['since'] = $contents['memberSince'][0];
    $user['rating'] = $contents['steamRating'][0];
    $user['hours_2wk'] = $contents['hoursPlayed2Wk'][0];
    $user['headline'] = $contents['headline'][0];
    $user['summary'] = $contents['summary'][0];


         $user['mostplayed']['mostplayed'] = $contents['statsName'][0];
    $user['mostplayed']['games'][$contents['gameName'][0]]['hours'] = $contents['hoursPlayed'][0];
    $user['mostplayed']['games'][$contents['gameName'][1]]['hours'] = $contents['hoursPlayed'][1];
    $user['mostplayed']['games'][$contents['gameName'][2]]['hours'] = $contents['hoursPlayed'][2];

         $user['mostplayed']['games'][$contents['gameName'][0]]['link'] = $contents['gameLink'][0];
    $user['mostplayed']['games'][$contents['gameName'][1]]['link'] = $contents['gameLink'][1];
    $user['mostplayed']['games'][$contents['gameName'][2]]['link'] = $contents['gameLink'][2];

         $user['mostplayed']['games'][$contents['gameName'][0]]['icon'] = $contents['gameIcon'][0];
    $user['mostplayed']['games'][$contents['gameName'][1]]['icon'] = $contents['gameIcon'][1];
    $user['mostplayed']['games'][$contents['gameName'][2]]['icon'] = $contents['gameIcon'][2];

         $user['mostplayed']['games'][$contents['gameName'][0]]['logo'] = $contents['gameLogo'][0];
    $user['mostplayed']['games'][$contents['gameName'][1]]['logo'] = $contents['gameLogo'][1];
    $user['mostplayed']['games'][$contents['gameName'][2]]['logo'] = $contents['gameLogo'][2];

         $user['mostplayed']['games'][$contents['gameName'][0]]['logo_s'] = $contents['gameLogoSmall'][0];
    $user['mostplayed']['games'][$contents['gameName'][1]]['logo_s'] = $contents['gameLogoSmall'][1];
    $user['mostplayed']['games'][$contents['gameName'][2]]['logo_s'] = $contents['gameLogoSmall'][2];


    $user['favgame']['name'] = $contents['name'][0];
    $user['favgame']['link'] = $contents['link'][0];
    $user['favgame']['logo'] = $contents['logo'][0];
    $user['favgame']['hours'] = $contents['hoursPlayed2wk'][0];

         if( $return_all == false )
         {
             return $user;
         }
         else
         {
             return $contents;
         }
}
$link = "https://steamcommunity.com/id/pfannkuchen_gesicht?xml=1";
$datas = getSteamprofile($link, 0);
echo "<pre>";print_r($datas);"</pre>";

 

Output:

[code]Array
(
[ingameinfo] => Array
(
[name] => Team Fortress 2
[link] => https://store.steampowered.com/app/440
[icon] => https://media.steampowered.com/steamcommunity/public/images/apps/440/e3f595a92552da3d664ad00277fad2107345f743.jpg
[logo] => https://media.steampowered.com/steamcommunity/public/images/apps/440/6f6d22ab0c357d9f02a11f76ff35797e4ccdf19f.jpg
[logo_s] => https://media.steampowered.com/steamcommunity/public/images/apps/440/d606e5858ff874b22647b6a2ae5f4d654eb2f4e5.jpg
)

[name] => pfannkuchen_gesicht
[state] => in-game
[msg] => In-Game

Team Fortress 2 - Join
[avatar] => https://media.steampowered.com/steamcommunity/public/images/avatars/74/74015438594ba8032cc41698bacc46deef2af787_full.jpg
[avatar_med] => https://media.steampowered.com/steamcommunity/public/images/avatars/74/74015438594ba8032cc41698bacc46deef2af787_medium.jpg
[avatar_ico] => https://media.steampowered.com/steamcommunity/public/images/avatars/74/74015438594ba8032cc41698bacc46deef2af787.jpg
[vac] => 0
[url] => pfannkuchen_gesicht
[since] => August 2, 2006
[rating] => 10
[hours_2wk] => 40.9
[headline] =>
[summary] => No information given.
[mostplayed] => Array
(
[mostplayed] => L4D
[games] => Array
(
[Left 4 Dead] => Array
(
[hours] => 18.5
[link] => https://store.steampowered.com/app/500
[icon] => https://media.steampowered.com/steamcommunity/public/images/apps/500/428df26bc35b09319e31b1ffb712487b20b3245c.jpg
[logo] => https://media.steampowered.com/steamcommunity/public/images/apps/500/0f67ee504d8f04ecd83986dd7855821dc21f7a78.jpg
[logo_s] => https://media.steampowered.com/steamcommunity/public/images/apps/500/0f67ee504d8f04ecd83986dd7855821dc21f7a78_thumb.jpg
)

                [Painkiller Gold Edition] => Array
                    (
                        [hours] => 9.9
                        [link] => https://store.steampowered.com/app/3200
                        [icon] => https://media.steampowered.com/steamcommunity/public/images/apps/3200/3e8830b9553bc7b12fb3762eec097b44551988b2.jpg
                        [logo] => https://media.steampowered.com/steamcommunity/public/images/apps/3200/915a8bef104490cc568d5eacb3df680e13f11bb9.jpg
                        [logo_s] => https://media.steampowered.com/steamcommunity/public/images/apps/3200/1bb33297854c09f996dc3d8480f35c565f03c728.jpg
                    )

                [Painkiller Overdose] => Array
                    (
                        [hours] => 6.8
                        [link] => https://store.steampowered.com/app/3270
                        [icon] => https://media.steampowered.com/steamcommunity/public/images/apps/3270/ab47a9209c8b6e7c5b81736a27489c9d22af46ff.jpg
                        [logo] => https://media.steampowered.com/steamcommunity/public/images/apps/3270/549dca50d8e2fd555a6abe115ac127731fc416a0.jpg
                        [logo_s] => https://media.steampowered.com/steamcommunity/public/images/apps/3270/2c3fbe2eceabe40c3cd98510b5ed51cd0e866a85.jpg
                    )

            )

    )

[favgame] => Array
    (
        [name] => Half-Life
        [link] => https://store.steampowered.com/app/70
        [logo] => https://media.steampowered.com/steamcommunity/public/images/apps/70/6bd76ff700a8c7a5460fbae3cf60cb930279897d.jpg
        [hours] => 0
    )

)
[/code]

EDIT:
example of use:
online

Ingame:

the joinbutton works!

Edit2:
another example:

and my last example:

EDIT: doublepost :facepalm:

Hmm, not bad. Does it always show 3 games, or anything over 0 hours?

only 3, the 3 most played.
btw: could someone make a better design for this?
EDIT:
Raminators profile:

cman2ks profile:

Is that just a image you’re using as the background?

yes, except the blue iconboxes.
but I can change that, if it’s easier to make designs for it

EDIT:
better font:

EDIT2:
improved design:

EDIT3:

EDIT4:
different styles:



EDIT5:
to make styles:
background image:
size 280x128px

border of avatar:
size [COLOR=‘Blue’]76x76 with an [COLOR=‘Black’]64x64 square( 6px offset )
( PNG, RGBA )

border for gameicons:
size [COLOR=‘Blue’]40x40 with an [COLOR=‘Black’]32x32 square( 4px offset )
( PNG, RGBA )

does someone know a free serverprovider with fopen wrappers activated?

EDIT:

[style]
background = steam_bg.png
avatar_border = steam_avatar_bg.png
game_border = steam_games_bg.png

[fonts]
steamID_color_r = 251
steamID_color_g = 235
steamID_color_b = 202
profileinfo_color_r = 251
profileinfo_color_g = 235
profileinfo_color_b = 202
gamename_color_r = 251
gamename_color_g = 235
gamename_color_b = 202
steamID_font = tf2secondary.ttf
profileinfo_font = tf2secondary.ttf
gamename_font = tf2secondary.ttf
steamID_fontsize = 16
profileinfo_fontsize = 9
gamename_fontsize = 12

[positions]
steamID_posX = 82
steamID_posY = 20
avatar_posX = 9
avatar_posY = 9
profileinfo_posX = 82
profileinfo_posY = 36
gamename_posX[] = 50
gamename_posY[] = 98
gamename_maxlen = 16
gamepic_posX[] = 9
gamepic_posY[] = 88
gamepic_posX[] = 195
gamepic_posY[] = 88
gamepic_posX[] = 240
gamepic_posY[] = 88

[appearance]
show_gamename[] = 1
show_gamename[] = 0
show_gamename[] = 0

[style]
background = steam_bg.png
avatar_border = steam_avatar_bg.png
game_border = steam_games_bg.png

[fonts]
steamID_color_r = 251
steamID_color_g = 235
steamID_color_b = 202
profileinfo_color_r = 251
profileinfo_color_g = 235
profileinfo_color_b = 202
gamename_color_r = 251
gamename_color_g = 235
gamename_color_b = 202
steamID_font = tf2secondary.ttf
profileinfo_font = tf2secondary.ttf
gamename_font = tf2secondary.ttf
steamID_fontsize = 16
profileinfo_fontsize = 9
gamename_fontsize = 12

[positions]
steamID_posX = 82
steamID_posY = 20
avatar_posX = 9
avatar_posY = 9
profileinfo_posX = 82
profileinfo_posY = 36
gamename_maxlen = 40
gamename_posX[] = 50
gamename_posY[] = 98
gamename_posX[] = 60
gamename_posY[] = 140
gamename_posX[] = 70
gamename_posY[] = 182
gamepic_posX[] = 9
gamepic_posY[] = 88
gamepic_posX[] = 19
gamepic_posY[] = 130
gamepic_posX[] = 29
gamepic_posY[] = 172

[appearance]
show_gamename[] = 1
show_gamename[] = 1
show_gamename[] = 1

Buy your own server? Not a whole lot of people will give you webspace for free with all the options you want.

and where to get the money from? printing some?
I have no workplace, where I could get some money from, I’m still learning.

Do what I do, sell stuff on Craigs list. Someone is coming over tonight to buy my 8800 GTS and possibly to rape me.

That is totally fucking cool.

Would you mind if I ripped off some of the code and tinkered with it to make my own version?

as soon as I think it’s ready

EDIT:

getSteamprofile


function getSteamprofile($url, $return_all = 0)
{
    $parser = xml_parser_create();
    xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
    xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
    $xml = file_get_contents($url);
    xml_parse_into_struct($parser, $xml, $value);
    xml_parser_free($parser);

         if($value[12]['tag'] === "inGameInfo")
         {
             $contents['inGameInfo'][] = $value[13]['value'];
             $contents['inGameInfo'][] = $value[14]['value'];
             $contents['inGameInfo'][] = $value[15]['value'];
             $contents['inGameInfo'][] = $value[16]['value'];
             $contents['inGameInfo'][] = $value[17]['value'];
             unset($value[13]);
             unset($value[14]);
             unset($value[15]);
             unset($value[16]);
             unset($value[17]);
             $user['ingameinfo']['name'] = $contents['inGameInfo'][0];
             $user['ingameinfo']['link'] = $contents['inGameInfo'][1];
             $user['ingameinfo']['icon'] = $contents['inGameInfo'][2];
             $user['ingameinfo']['logo'] = $contents['inGameInfo'][3];
             $user['ingameinfo']['logo_s'] = $contents['inGameInfo'][4];
         }
         else
         {
         }

    foreach( $value as $values )
    {
             $contents[$values['tag']][] = $values['value'];
    }
         unset($contents['inGameInfo'][5]);
         unset($contents['inGameInfo'][6]);

    $user['name'] = $contents['steamID'][0];
    $user['state'] = $contents['onlineState'][0];
    $user['msg'] = $contents['stateMessage'][0];
    $user['avatar'] = $contents['avatarFull'][0];
    $user['avatar_med'] = $contents['avatarMedium'][0];
    $user['avatar_ico'] = $contents['avatarIcon'][0];
    $user['vac'] = $contents['vacBanned'][0];
    $user['url'] = $contents['customURL'][0];
    $user['since'] = $contents['memberSince'][0];
    $user['rating'] = $contents['steamRating'][0];
    $user['hours_2wk'] = $contents['hoursPlayed2Wk'][0];
    $user['headline'] = $contents['headline'][0];
    $user['summary'] = $contents['summary'][0];


         $user['mostplayed']['mostplayed'] = $contents['statsName'][0];
    $user['mostplayed']['games'][$contents['gameName'][0]]['hours'] = $contents['hoursPlayed'][0];
    $user['mostplayed']['games'][$contents['gameName'][1]]['hours'] = $contents['hoursPlayed'][1];
    $user['mostplayed']['games'][$contents['gameName'][2]]['hours'] = $contents['hoursPlayed'][2];

         $user['mostplayed']['games'][$contents['gameName'][0]]['link'] = $contents['gameLink'][0];
    $user['mostplayed']['games'][$contents['gameName'][1]]['link'] = $contents['gameLink'][1];
    $user['mostplayed']['games'][$contents['gameName'][2]]['link'] = $contents['gameLink'][2];

         $user['mostplayed']['games'][$contents['gameName'][0]]['icon'] = $contents['gameIcon'][0];
    $user['mostplayed']['games'][$contents['gameName'][1]]['icon'] = $contents['gameIcon'][1];
    $user['mostplayed']['games'][$contents['gameName'][2]]['icon'] = $contents['gameIcon'][2];

         $user['mostplayed']['games'][$contents['gameName'][0]]['logo'] = $contents['gameLogo'][0];
    $user['mostplayed']['games'][$contents['gameName'][1]]['logo'] = $contents['gameLogo'][1];
    $user['mostplayed']['games'][$contents['gameName'][2]]['logo'] = $contents['gameLogo'][2];

         $user['mostplayed']['games'][$contents['gameName'][0]]['logo_s'] = $contents['gameLogoSmall'][0];
    $user['mostplayed']['games'][$contents['gameName'][1]]['logo_s'] = $contents['gameLogoSmall'][1];
    $user['mostplayed']['games'][$contents['gameName'][2]]['logo_s'] = $contents['gameLogoSmall'][2];


    $user['favgame']['name'] = $contents['name'][0];
    $user['favgame']['link'] = $contents['link'][0];
    $user['favgame']['logo'] = $contents['logo'][0];
    $user['favgame']['hours'] = $contents['hoursPlayed2wk'][0];

         if( $return_all == false )
         {
             return $user;
         }
         else
         {
             return $contents;
         }
}
 

raw_bean, do you know about the GDLib?

EDIT: removed Imagecreation code.

i wanted to say just that , omg you people are really cool

I’d never heard about it until you mentioned it, but I just looked it up. Looks interesting, I might have a fiddle with it. Why do you ask?

'cause of the generated image examples.
I thought you’ll do something like this.

I really like what you are doing. PM me and i’ll host you :3

Could you make it work for this design?

Here’s the blank card:

Cause I’d really love a simple and compact steam card like that! Especially if I can host my own and not have to rely on some other site. :smiley:

btw, the font is Verdana.

yes, of course.
I’ll work on it.
on your own server?
keep in mind, you must have fopen_wrappers activated.

EDIT: did you make the card design?

Founded in 2004, Leakfree.org became one of the first online communities dedicated to Valve’s Source engine development. It is more famously known for the formation of Black Mesa: Source under the 'Leakfree Modification Team' handle in September 2004.