Jump to content

Steam Feed and PHP Loop problems


SamT

Recommended Posts

Hey guys,

 

I'm fairly new to PHP but i know the basics. I've been working with the Steam XML feeds for various reasons and i'm trying to create a list of friends that show whether they are online/offline, show their profile pic... etc...

 

To get a persons friends list (using me as an example) is: http://steamcommunity.com/profiles/76561197970734089/friends?xml=1

But to get to get more information from the friends you take the steamID from the above XML and take information from their main profile XML feed, i have to do this because the normal profile XML (again as me as an example): http://steamcommunity.com/profiles/76561197970734089?xml=1 , only displays 6 friends details at a time.

 

I hope you under stand but please see my PHP below, the problem i'm having is that it takes forever to run the loop and certain mobile browsers just wont display the page (timeout). I didn't know whether you guys being the phpfreaks would know of a faster memory efficient way of doing this?

 

  // set the XML file name as a PHP string
  $friendslist = "http://steamcommunity.com/profiles/76561197970734089/friends/?xml=1" ; 
  
  // load the XML file 
  $xml = @simplexml_load_file($friendslist) or die ("no file loaded") ; 
  
  // get the output
  $steamID = $xml->steamID ;
  echo "<h1>Main Profile: " . $steamID . "</h1>";
  
  // set the loop
  foreach ($xml->friends->children() as $friendid) {
  echo "http://steamcommunity.com/profiles/".$friendid."?xml=1" ;
  echo "<br />";
  $friendget = "http://steamcommunity.com/profiles/".$friendid."?xml=1" ;
  $friendgot = @simplexml_load_file($friendget) or die ("no file loaded") ;
  echo $friendgot->steamID ;
  echo "<br />" ;
  }

Link to comment
https://forums.phpfreaks.com/topic/209423-steam-feed-and-php-loop-problems/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.