Jump to content

Recommended Posts

I am calling members gamer tags out of the database and then passing them to xbox live to get there online status. the problem i have is I cant pull more than about 10 at a time or it times out

i dont have the option of increasing the time out limit,

 

$result = mysql_query ("SELECT id_member, gamer_xbgt FROM smf_members");

while($row = mysql_fetch_array($result)) {

 $gamertag =  $row['gamer_xbgt'];

 if (!empty($gamertag)) {

   $html = file_get_html ('https://live.xbox.com/en-US/Profile?Gamertag=' . urlencode ($gamertag));
foreach ($html->find('div[class=presence] ') as $e)


  echo $row['id_member']  . " " . $gamertag . " " . $e->innertext;
  echo "<br />";

 }
}

 

what would be the best solution to solve timeout problems,

Link to comment
https://forums.phpfreaks.com/topic/270354-script-time-out/
Share on other sites

set_time_limit($seconds);

If you are going to do this very often, then I bet ms won't be too happy about it.

I hope you cache the data and only update every x hour or so.

While fetching the data you should be nice to the server, only send a request every x second.

sleep($seconds);

^ That allows your script to sleep.

Remember whenever you sleep you should make the time limit a bit larger.

So basically you should create a function that will run after each fetch which adds the delay time and the extra time it takes for the new fetch.

Link to comment
https://forums.phpfreaks.com/topic/270354-script-time-out/#findComment-1390524
Share on other sites

I will only be running this twice a day and yes i will be caching the data

 

i can not use set_time_limit due to the system policy of our host

 

so is there another way this can be done maybe do it in chunks at a time ?

You can do it chunks at a time if you'd like.

It could be a page that require some GET data to decide who to update, maybe a "password" to verify it's you it's the script that activated this update.

Like this:

http://www.example.com/updatescript.php?u=MMDE&pw=somesecretpw

 

updatescript.php file:

function update($username){
// your update script
}

function valid_user($username){
$valid_users = array('MMDE', 'far2slow');
if(in_array($username, $valid_users)) return true;
return false;
}

if(!(!empty($_GET['pw']) && $_GET['pw']=='somesecretpw' && !empty($_GET['u']) && !valid_user($_GET['u']))) exit();
update($_GET['u']);

 

You will need a script that loops through all of the users and visits the site with the appropriate get values in the url.

I don't think you can use cURL for this, as it will wait for the responds and get that. You just want to initialize the connection.

 

 

Another solution may also be to fork, but I'm not sure if it gets affected by time limit.

Edited by MMDE
Link to comment
https://forums.phpfreaks.com/topic/270354-script-time-out/#findComment-1390557
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.