Jump to content

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.

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.