Raised This Month: $32 Target: $400
 8% 

Steam Group XML help ?


Post New Thread Reply   
 
Thread Tools Display Modes
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 01-12-2016 , 13:47   Re: Steam Group XML help ?
Reply With Quote #11

Quote:
Originally Posted by SychO View Post
so basically there is no way to make this work better is there ?
Nope, not unless you can speed up the time it takes for the request to reach Valve's webservers and the speed at which it takes the response to reach your webservers.

Another option is to cut out the request for the player's profile.

Last edited by WildCard65; 01-12-2016 at 13:48.
WildCard65 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 01-12-2016 , 13:49   Re: Steam Group XML help ?
Reply With Quote #12

Quote:
Originally Posted by SychO View Post
so basically there is no way to make this work better is there ?
why are you retrieving it so often?
Mitchell is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 01-12-2016 , 14:40   Re: Steam Group XML help ?
Reply With Quote #13

Cache it every day or however often :9
Miu is offline
SychO
Junior Member
Join Date: Jan 2016
Old 01-12-2016 , 14:55   Re: Steam Group XML help ?
Reply With Quote #14

Quote:
Originally Posted by Mitchell View Post
why are you retrieving it so often?
i didn't understand your question,

this is shown in a community portal , so people access the page a lot,
SychO is offline
Akuba
Senior Member
Join Date: Oct 2013
Old 01-12-2016 , 15:43   Re: Steam Group XML help ?
Reply With Quote #15

Quote:
Originally Posted by SychO View Post
this is shown in a community portal , so people access the page a lot,
Just because of that I would say you should cache the result. It will:
A: Save traffic.
B: Improve the performance of the webserver. (aka the Page will build/send faster.)
C: Also be available when Steam is down.

Last edited by Akuba; 01-12-2016 at 15:44.
Akuba is offline
SychO
Junior Member
Join Date: Jan 2016
Old 01-12-2016 , 16:27   Re: Steam Group XML help ?
Reply With Quote #16

Quote:
Originally Posted by Akuba View Post
Just because of that I would say you should cache the result. It will:
A: Save traffic.
B: Improve the performance of the webserver. (aka the Page will build/send faster.)
C: Also be available when Steam is down.
well the problem is that my full code shows the group members online and in-game,, caching would not refresh the stats i think, it wouldn't do the why i made it
SychO is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 01-12-2016 , 16:42   Re: Steam Group XML help ?
Reply With Quote #17

Quote:
Originally Posted by SychO View Post
well the problem is that my full code shows the group members online and in-game,, caching would not refresh the stats i think, it wouldn't do the why i made it
here's a thought:
don't do that.

Atleast cache the group members and use some kind of javascript on the page to iterate through the members to check if they are online or something. (After the page loads so you're not having people sit at a blank screen.)
Mitchell is offline
Disowned
Member
Join Date: Oct 2015
Old 01-12-2016 , 20:35   Re: Steam Group XML help ?
Reply With Quote #18

The problem you have is that steam groups can be quite large. Iterating over all of the data on each page visit isn't going to work at all. If you're building a system that HAS to keep track of all players in the group, then you would need to build an API of your own that communicates with the valve API's and creates a cache of the users.

You don't have to send a request per-user, but you are limited to 100 per request to the API.

Here is how you would get the first 100 users in a group. Any further requires that multiple requests be made with a maximum player limit of 100.

Fill in the API Key and what group you're looking at. DONT SHARE YOUR API KEY ON THE FORUMS.
PHP Code:
<?php 
//Turn off errors in production since they can potentially reveal request information.
//error_reporting(0);
//Uncomment before public

/* A Generic GET request with cURL
 * String $cURL - URL to request
 * return array    
 */
function ValveGET_cURL($cURL) {

    
$request curl_inittrim($cURL) );
    
curl_setopt$requestCURLOPT_RETURNTRANSFERTRUE );
    
curl_setopt$requestCURLOPT_FOLLOWLOCATIONTRUE );
    
curl_setopt$requestCURLOPT_MAXREDIRS3);
    
curl_setopt$requestCURLOPT_AUTOREFERERTRUE);
    
curl_setopt$requestCURLOPT_CONNECTTIMEOUT5);
    
curl_setopt$requestCURLOPT_TIMEOUT10);
    
$result curl_exec$request );
    
$info curl_getinfo$request );
    
$error curl_errno$request );
    
curl_close$request );
    return array(
'data' => $result'info' => $info'error' => $error);
}

$groupid "steamuniverse";
$API_KEY "FILL THIS";


$group_URL 'http://steamcommunity.com/groups/' $groupid '/memberslistxml/?xml=1';

$return_array ValveGET_cURL($group_URL);
$return_data $return_array['data'];
$return_info $return_array['info'];
$return_error $return_array['error'];

//handle cURL errors
if($return_error !== 0) {
    
error_log("Steam Group Thingy returned with cURL Error: " $return_error0);
    exit;
}

$http_code $return_info['http_code'];
if(
$http_code !== 200) {
    
//Server is probably down, give a generic message if you want
    
echo "Steam API is down";
    exit;
} else {
    
//Request was successfull
    
$group_object simplexml_load_string($return_data);
    
$group_object_members $group_object->members->steamID64;

    
$steamids = array();

    foreach(
$group_object_members as $user) {
        
$string = (string)$user;
        if(
ctype_digit($string)) {
            
$steamids[] = $string;
        }
    }

    
//Turn the first 100 or less into a string for the request.
    
$idcount count($steamids);
    
$x = ($idcount 100) ? $idcount 100;
    
$giantlistofusers "";
    for(
$i 0$i $x$i++) {

        
$giantlistofusers .= $steamids[$i];
        if(
$i <= $x) {
            
$giantlistofusers .= ',';    
        }
    }
    
$request_URL2 'http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' $API_KEY '&steamids=' urlencode($giantlistofusers) . '&format=xml';

    
$player_return ValveGET_cURL($request_URL2 );

    
$player_data $player_return['data'];
    
$player_info $player_return['info'];
    
$player_error $player_return['error'];

    
//handle cURL errors
    
if($player_error !== 0) {
        
error_log("Steam Group Thingy returned with cURL Error: " $player_error0);
        exit;
    }

    
$http_code2 $player_info['http_code'];
    if(
$http_code2 !== 200) {
        
//Server is probably down, give a generic message if you want
        
echo "Steam API is down";
        exit;
    } else {

        
$player_object simplexml_load_string($player_data);

        
var_dump($player_object->players);
    }
}


?>


In order to make it complete you would have to enumerate how many users per memberslist page, send a request for each 100, then get the next memberlist page and keep going until all steamID64 ID's have been accounted for.

Again, this isn't necessary if you look at specific users rather than trying to get an entire group.
Disowned 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 19:00.


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