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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.