far2slow Posted July 22, 2011 Share Posted July 22, 2011 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 />'; Quote Link to comment https://forums.phpfreaks.com/topic/242622-how-can-i-speed-this-up/ Share on other sites More sharing options...
teynon Posted July 22, 2011 Share Posted July 22, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/242622-how-can-i-speed-this-up/#findComment-1246096 Share on other sites More sharing options...
far2slow Posted July 22, 2011 Author Share Posted July 22, 2011 that makes sence but once i have done the include ("$sourcedir/xboxapi.php"); how do i get it to run ?gamertag=".urlencode($gamertag); for each user Quote Link to comment https://forums.phpfreaks.com/topic/242622-how-can-i-speed-this-up/#findComment-1246148 Share on other sites More sharing options...
dcro2 Posted July 23, 2011 Share Posted July 23, 2011 Maybe you can make whatever's in that file into a function instead, then you can call something like xboxapi_get($gamertag);. Use $gamertag in your code instead of $_GET['gamertag']. Quote Link to comment https://forums.phpfreaks.com/topic/242622-how-can-i-speed-this-up/#findComment-1246404 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.