Go Back   Steam Users' Forums > Steam Discussions > Steam Community Discussion

Reply
 
Thread Tools Display Modes
Old 09-17-2009, 12:38 AM   #1
jessay
 
 
 
Guest
Posts: n/a
XML Parser? API? Steam Group Stats on Webpage?

I have been trying for quite to locate these xml parsers everyone keeps saying they have that allow the integration of the steam community group and your website. All I would like to do is display any persons in my steam group, their achievements, avatar, minimal if there are any that do more that's awesome but I'd be grateful for just that.
 
Reply With Quote
Old 09-17-2009, 01:31 AM   #2
timgames
 
Join Date: Mar 2007
Reputation: 0
Posts: 36
I don't know what coding language you use but this can maybe help you
http://steamcommunity.com/gid/<YOUR GROUP ID>/memberslistxml/?xml=1
timgames is offline   Reply With Quote
Old 09-17-2009, 03:25 AM   #3
Slayer00
 
 
 
Join Date: Sep 2006
Reputation: 1100
Posts: 5,486
I also would want pre-made XML parser PHP script.. If anyone has post some here, please.
Slayer00 is offline   Reply With Quote
Old 09-17-2009, 03:37 AM   #4
SquareDisc
 
 
 
Join Date: Oct 2005
Reputation: 17
Posts: 195
write ur own, their not hard

http://www.w3schools.com/PHP/php_xml_simplexml.asp
SquareDisc is offline   Reply With Quote
Old 09-17-2009, 03:41 AM   #5
Slayer00
 
 
 
Join Date: Sep 2006
Reputation: 1100
Posts: 5,486
Quote:
Originally Posted by SquareDisc View Post
I tried.. It didn't work, at all.
Im total noob with PHP.
Slayer00 is offline   Reply With Quote
Old 09-17-2009, 05:10 AM   #6
SquareDisc
 
 
 
Join Date: Oct 2005
Reputation: 17
Posts: 195
heres a script i wrote to grab a steam community group info

usage eg. http://www.yoururl.com/group.php?group=clan-killers
live eg. http://www.clan-killers.com/group.ph...p=clan-killers

this isn't the cleanest script but it works

Code:
<?php 
 
// ######################### STEAM COMMUNITY ############################# 
$group = $_GET['group']; 
 
// ######################### STEAM COMMUNITY ############################# 76561197965857367 
 
	$url = file_get_contents('http://steamcommunity.com/groups/'.$group); 
	ini_set('default_socket_timeout', 0); 
	preg_match('#<h1>(.+)</h1>#sU', $url, $aMatches); 
	echo "<a class='clanname' href='http://steamcommunity.com/groups/$group' target='_blank'>$aMatches[1]</a>"; 
	echo "<br>";

	preg_match('#<div class="groupMemberRow">(.+)</div>#sU', $url, $aMatches); 
	$aMatches = str_replace('class="linkStandard"', 'class="linkStandard" target="_blank"', $aMatches[1]);
	echo "<span class='resultsb'>$aMatches</span>"; 
	echo "<br>";

	preg_match('#<div class="statsItemName">Steam Rating:</div>(.+)</div>#sU', $url, $aMatches); 
	echo "<span class='results'>Steam Rating:</span> ";
	echo "<span class='resultsb'>$aMatches[1]</span>"; 
	echo "<br>";
	preg_match('#<div class="statsItemName">Playing time:</div>(.+)</div>#sU', $url, $aMatches); 
	echo "<span class='results'>Playing Time:</span> ";
	echo "<span class='resultsb'>$aMatches[1]</span>";
	echo "<br>";
	preg_match('#<div class="statsItemName">Member Avg:</div>(.+)</div>#sU', $url, $aMatches); 
	echo "<span class='results'>Member Avg:</span> ";
	echo "<span class='resultsb'>$aMatches[1]</span>";
	echo "<br>";
	preg_match('#Counter-Strike:.*Source<br.*/>.*<span.*class="mostPlayedSmallText".*>(.+)</div>#sU', $url, $aMatches); 
	echo "<table><tr><td>";
	echo "<img src='http://media.steampowered.com/steamcommunity/public/images/apps/240/3c7eb54d85e0317d8474858537bd2a26b85a64fa.jpg' align='absmiddle'> ";
	echo "<span class='resultsb'>$aMatches[1]</span>";
	preg_match('#Team.*Fortress.*2<br.*/>.*<span.*class="mostPlayedSmallText".*>(.+)</div>#sU', $url, $aMatches); 
	echo "</td><td>";
	echo "<img src='http://media.steampowered.com/steamcommunity/public/images/apps/440/e3f595a92552da3d664ad00277fad2107345f743.jpg' align='absmiddle'> ";
	echo "<span class='resultsb'>$aMatches[1]</span>";
	echo "</td><td>";
	preg_match('#Left.*4.*Dead<br.*/>.*<span.*class="mostPlayedSmallText".*>(.+)</div>#sU', $url, $aMatches); 
	echo "<img src='http://media.steampowered.com/steamcommunity/public/images/apps/500/428df26bc35b09319e31b1ffb712487b20b3245c.jpg' align='absmiddle'> ";
	echo "<span class='resultsb'>$aMatches[1]</span>";
	echo "</td></tr></table>";


	preg_match('#<div class="avatarHolder_default"><div class="avatarFull"><img src="(.+)" /></div>#sU', $url, $aMatches); 
?>
this script does the same sort of thing but for users

usage eg. http://www.yoururl.com/games.php?gam...AM_0:1:2795819
live eg. http://www.clan-killers.com/games.ph...AM_0:1:2795819

Code:
<?php
$align = $_GET['align'];
if($align != "")
	{
		echo '<table width="184" align="'.$align.'"><tr><td>';
	}
// ######################### STEAM COMMUNITY #############################
$steamid = $_GET['id'];
$gameid = $_GET['game'];
$friendid = steam2friend($steamid);

function steam2friend($steam_id){
    $steam_id=strtolower($steam_id);
    if (substr($steam_id,0,7)=='steam_0') {
        $tmp=explode(':',$steam_id);
        if ((count($tmp)==3) && is_numeric($tmp[1]) && is_numeric($tmp[2])){
            return bcadd((($tmp[2]*2)+$tmp[1]),'76561197960265728');
        }else return false;
        }else{
            return false;
        }
    }

// ######################### STEAM COMMUNITY ############################# 76561197965857367

	$url = file_get_contents('http://steamcommunity.com/profiles/'.$friendid.'/stats/'.$gameid.'?tab=stats');
	preg_match('#<div class="gameLogo">(.+)</div>#sU', $url, $aMatches);
	preg_match('#<img src="(.+)" /></a>#sU', $aMatches[1], $aMatches);
	if($gameid != "CSS")echo '<a href="http://steamcommunity.com/profiles/'.$friendid.'" target="_blank"><img src="'.$aMatches[1].'"></a>';
	if($gameid == "CSS")echo '<a href="http://steamcommunity.com/profiles/'.$friendid.'" target="_blank"><img src="http://media.steamcommunity.com/steamcommunity/public/images/apps/240/2829d85b338a3bc2d10e2f39c9339d785ad8fcd2.jpg" border="0"></a>';
	printf("\n<br />\n");
	preg_match('#<h1>(.+)</h1>#sU', $url, $aMatches);
	echo " - $aMatches[1]";
	printf("\n<br />\n");
// ## CSS
if($gameid == "CSS"){
	echo " - $steamid";
	printf("\n<br />\n");
	$url = file_get_contents('http://steamcommunity.com/profiles/'.$friendid.'/games/');
	preg_match('#<h4>Counter-Strike:.*Source</h4.*>(.+)</h5>#isU', $url, $aMatches);
	$aMatches[1] = trim($aMatches[1]);
	$aMatches[1] = substr($aMatches[1], 10);
	echo " - $aMatches[1]";
	printf("\n<br />\n");
}
// ## L4D
if($gameid == "L4D"){
	preg_match('#<div id="topSummaryAchievements">(.+)Achievements Earned::<br />#sU', $url, $aMatches);
	echo " - $aMatches[1]";
	printf("\n<br />\n");
	preg_match('#s<br />(.+)</div>#', $url, $aMatches);
	echo " - $aMatches[1]";
	printf(" past 2 weeks\n<br />\n");
}
// ## TF2
if($gameid == "TF2"){
	preg_match('#<div class="achievementStatusLeft">Personal Achievements Earned:</div>(.+)</div>#sU', $url, $aMatches);
	echo " - $aMatches[1]";
	printf("\n<br />\n");
	preg_match('#Playtime:<br />(.+)<div id="playtimeFooter">#sU', $url, $aMatches);
	echo " - $aMatches[1]";
	printf("\n<br />\n");
}
// ## Killing Floor
if($gameid == "KillingFloor"){
	preg_match('#<div id="topSummaryAchievements">(.+)Achievements Earned::<br />#sU', $url, $aMatches);
	echo " - $aMatches[1]";
	printf("\n<br />\n");
	preg_match('#<div id="tsblVal">(.+)</div>#sU', $url, $aMatches);
	echo " - $aMatches[1]";
	printf(" past 2 weeks\n<br />\n");
}
// ## DOD Source
if($gameid == "DOD:S"){
	preg_match('#<div id="topSummaryAchievements">(.+)Achievements Earned::<br />#sU', $url, $aMatches);
	echo " - $aMatches[1]";
	printf("\n<br />\n");
	preg_match('#<div id="tsblVal">(.+)</div>#sU', $url, $aMatches);
	echo " - $aMatches[1]";
	printf(" past 2 weeks\n<br />\n");
}


echo '<a href="games.php?game=CSS&id='.$steamid.'"><img src="http://media.steamcommunity.com/steamcommunity/public/images/apps/240/3c7eb54d85e0317d8474858537bd2a26b85a64fa.jpg" border="0" alt="CSS" title="CSS"></a>';
echo '<a href="games.php?game=TF2&id='.$steamid.'"><img src="http://media.steamcommunity.com/steamcommunity/public/images/apps/440/e3f595a92552da3d664ad00277fad2107345f743.jpg" border="0" alt="TF2" title="TF2"></a>';
echo '<a href="games.php?game=L4D&id='.$steamid.'"><img src="http://media.steamcommunity.com/steamcommunity/public/images/apps/500/428df26bc35b09319e31b1ffb712487b20b3245c.jpg" border="0" alt="L4D" title="L4D"></a>';
echo '<a href="games.php?game=KillingFloor&id='.$steamid.'"><img src="http://media.steamcommunity.com/steamcommunity/public/images/apps/1250/d8a2d777cb4c59cf06aa244166db232336520547.jpg" border="0" alt="KillingFloor" title="KillingFloor"></a>';
echo '<a href="games.php?game=DOD:S&id='.$steamid.'"><img src="http://media.steamcommunity.com/steamcommunity/public/images/apps/300/062754bb5853b0534283ae27dc5d58200692b22d.jpg" border="0" alt="DOD:S" title="DOD:S"></a>';
?>
</td></tr></table>

Last edited by SquareDisc: 09-17-2009 at 05:15 AM.
SquareDisc is offline   Reply With Quote
Old 09-17-2009, 05:39 AM   #7
Fuzz Bucket
 
Banned
Join Date: Jul 2006
Reputation: 2337
Posts: 4,549
Yea... I wrote a PHP Class for the Community a while back... I haven't updated it since Valve started supplying XML because I thought people could handle it from there. :P
Fuzz Bucket is offline   Reply With Quote
Old 09-17-2009, 07:11 AM   #8
Pc_Madness
 
Join Date: Aug 2007
Reputation: 78
Posts: 2,130
Its part of a work in progress, but you can give this a whirl,

http://www.phillipmccallum.com/proje...2stats.php.txt
and is used like thus,

$Player = TF2StatViewer::GetProfile($PlayerName, $ProfileID);

$Player->TF2Stats = an array of class objects for you to work with.

It belongs to part of this, but its still a work in progress and is abit buggy and may look crap in some browsers,
http://www.phillipmccallum.com/projects/tf2stats/

If you see any bugs in the code above, let me know.
Pc_Madness is offline   Reply With Quote
Old 09-17-2009, 10:40 AM   #9
Slayer00
 
 
 
Join Date: Sep 2006
Reputation: 1100
Posts: 5,486
Quote:
Originally Posted by SquareDisc View Post
heres a script i wrote to grab a steam community group info

usage eg. http://www.yoururl.com/group.php?group=clan-killers
live eg. http://www.clan-killers.com/group.ph...p=clan-killers

this isn't the cleanest script but it works

....source code....
Thanks for this!
No matter if its clean or not I learn from ready made stuff lot easier than hard and unclear/unfinished examples..
(coding nowadays.. copy -> paste -> edit -> publish )
Quote:
Originally Posted by Fuzz Bucket View Post
Yea... I wrote a PHP Class for the Community a while back... I haven't updated it since Valve started supplying XML because I thought people could handle it from there. :P
I noticed it too late, the links for source codes are invalid, could you re-upload?
Quote:
Originally Posted by Pc_Madness View Post
Its part of a work in progress, but you can give this a whirl,

http://www.phillipmccallum.com/proje...2stats.php.txt
and is used like thus,

$Player = TF2StatViewer::GetProfile($PlayerName, $ProfileID);

$Player->TF2Stats = an array of class objects for you to work with.

It belongs to part of this, but its still a work in progress and is abit buggy and may look crap in some browsers,
http://www.phillipmccallum.com/projects/tf2stats/

If you see any bugs in the code above, let me know.
Im not TF2 player really but I guess this script helps me to learn, thanks!
Slayer00 is offline   Reply With Quote
Old 09-17-2009, 12:21 PM   #10
Fuzz Bucket
 
Banned
Join Date: Jul 2006
Reputation: 2337
Posts: 4,549
Quote:
Originally Posted by Slayer00 View Post
Thanks for this!
No matter if its clean or not I learn from ready made stuff lot easier than hard and unclear/unfinished examples..
(coding nowadays.. copy -> paste -> edit -> publish )

I noticed it too late, the links for source codes are invalid, could you re-upload?

Im not TF2 player really but I guess this script helps me to learn, thanks!
They have made too many changes to the DOM of the community pages since I last updated it.
Fuzz Bucket is offline   Reply With Quote
Old 09-17-2009, 06:51 PM   #11
Pc_Madness
 
Join Date: Aug 2007
Reputation: 78
Posts: 2,130
Quote:
Originally Posted by Slayer00 View Post
Im not TF2 player really but I guess this script helps me to learn, thanks!
The code for the profile is in there as well. Just comment out line 104 to line 113 and it'll just return details about your account. Theres group details available as well, but I haven't included that in my code.
Pc_Madness is offline   Reply With Quote
Old 09-19-2009, 03:18 AM   #12
Pc_Madness
 
Join Date: Aug 2007
Reputation: 78
Posts: 2,130
Quote:
Originally Posted by Pc_Madness View Post
The code for the profile is in there as well. Just comment out line 104 to line 113 and it'll just return details about your account. Theres group details available as well, but I haven't included that in my code.
Gah, what am I saying,

$Player = TF2StatViewer::GetProfile($PlayerName, $ProfileID, false);

Will prevent it from getting TF2 stats.

I've updated the script if anyone was using the original, better error handling for not being able to find the profile / stats + whether or not the stats are cached or not.
Pc_Madness is offline   Reply With Quote
Old 09-25-2009, 07:03 AM   #13
Mr.Roost3r
 
 
 
Guest
Posts: n/a
Is there anyway to parse an the exl using <steamID64> instead of <steamID> to gather information. The parse script I have will gather the info I need when I use (my profile):

http://steamcommunity.com/id/tehrooster?xml=1

but when I try to use:

http://steamcommunity.com/profile/76...2461249r?xml=1

The script will not get the info. I see that when I try to connect to the profile xml, I'm redirected to the login page.
  Reply With Quote
Old 09-25-2009, 07:12 AM   #14
Fuzz Bucket
 
Banned
Join Date: Jul 2006
Reputation: 2337
Posts: 4,549
Quote:
Originally Posted by Mr.Roost3r View Post
Is there anyway to parse an the exl using <steamID64> instead of <steamID> to gather information. The parse script I have will gather the info I need when I use (my profile):

http://steamcommunity.com/id/tehrooster?xml=1

but when I try to use:

http://steamcommunity.com/profile/76...2461249r?xml=1

The script will not get the info. I see that when I try to connect to the profile xml, I'm redirected to the login page.
Use something that will handle redirects.
Fuzz Bucket is offline   Reply With Quote
Old 09-25-2009, 08:50 AM   #15
timgames
 
Join Date: Mar 2007
Reputation: 0
Posts: 36
Quote:
Originally Posted by Fuzz Bucket View Post
Use something that will handle redirects.
I think the people at valve already fixed that.

yea they did.
http://steamcommunity.com/profiles/7...93560336?xml=1

also note it's /profiles/ not /profile/

Code:
http://steamcommunity.com/profiles/<steamid64>?xml=1

Last edited by timgames: 09-25-2009 at 08:52 AM.
timgames is offline   Reply With Quote
Reply

Go Back   Steam Users' Forums > Steam Discussions > Steam Community Discussion


Thread Tools
Display Modes

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 Off
HTML code is Off



All times are GMT -7. The time now is 08:48 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site Content Copyright Valve Corporation 1998-2012, All Rights Reserved.