Jump to content

how can i speed this up


far2slow

Recommended Posts

this works but it takes way to long to get the screen scrap data from xboxapi for each user is there a better way of doing this?

 

		foreach ($group['members'] as $pos => $data)
				{
					foreach ($data as $member)
					{
						 $gamertag =  $member['gamername'];
              $url = "http://www.oldgamerz.co.uk/xboxapi/xboxapi.php?gamertag=".urlencode($gamertag);
              $output = file_get_contents($url);
              $json = json_decode(utf8_encode($output), true);
			$xboxonline = $json['response'][0]['user']['is_online'];
		  $xboxonline_status = $json['response'][0]['user']['online_status'];			

						echo '
					<tr class="windowbg2">
						<td align="center">';
						echo '
						</td>
						<td  align="left" style="padding: 0mm">
							<div align="left" style="padding-left: 20px;">
								<img src="', $member['online']['image_href'], '" alt="', $member['online']['link'], '" /> <span class="smalltext">', $member['link'], ' ' ;
if ($xboxonline == "0")
echo '<span style="color: red">Off line</span>';
else echo '<span style="color: green">Online</span>';
echo ' ', $xboxonline_status; echo'</span><br />';

Link to comment
https://forums.phpfreaks.com/topic/242622-how-can-i-speed-this-up/
Share on other sites

Your loading another page every time you show something:

 

$url = "http://www.oldgamerz.co.uk/xboxapi/xboxapi.php?gamertag=".urlencode($gamertag);

$output = file_get_contents($url);

 

If it is a local url, you should request it locally via include or a function. Otherwise, your best bet is to cache the data on your server and update it only when it's old. It will take longer the first time and then after that, it should go faster depending on when the last time it was updated.

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.