Jump to content

Recommended Posts

I have a php that get's tweets from 102 people to store them in a database.

Only i get a error about a time limit exceded (60sec).

I tried to solve it by this:

 

if($id <= 150){
$id ++;
$headerLoc = "updateTweets.php";
header("Location: ".$headerLoc."?id=".$id."");
}
else {
echo "done ok";
}

 

 

but then i get a error from chrome that the site has a redirect loop (it comes to 22).

What would be a good way to solve?

Link to comment
https://forums.phpfreaks.com/topic/239371-too-many-redirects/
Share on other sites

I'm not really sure I understand your problem. What is the error about a time limit coming from? Twitter?

 

But the reason for the infinite redirect is because you are basically saying "if $id is less than 150, keep redirecting until it equals 150". So if $id is equal to 1, it's going to redirect 149 times before it gets to 150. Not really sure what you are trying to accomplish with that, to be honest.

Link to comment
https://forums.phpfreaks.com/topic/239371-too-many-redirects/#findComment-1229745
Share on other sites

I can't remember the exact error, problem is i can't look at it cause then i hit a 150 request per hour limit by twitter and that makes me have to wait an hour before i can continue working.

It's something that it takes to long before the site is ready loading.

 

For the redirect thing, it was to avoid that page loading takes to long.

Since it would now take 150 times less long.

Link to comment
https://forums.phpfreaks.com/topic/239371-too-many-redirects/#findComment-1229752
Share on other sites

I can't remember the exact error, problem is i can't look at it cause then i hit a 150 request per hour limit by twitter and that makes me have to wait an hour before i can continue working.

It's something that it takes to long before the site is ready loading.

 

So once again was the error FROM twitter? If you are being limited by their API then there probably isn't anything you can do about it.

 

For the redirect thing, it was to avoid that page loading takes to long.

Since it would now take 150 times less long.

 

How would it take 150x less time if you have to load it 150x more?

 

 

Link to comment
https://forums.phpfreaks.com/topic/239371-too-many-redirects/#findComment-1229756
Share on other sites

no not from twitter,

 

and for the less time, the total time to update all 150 will be the same it just:

 

1:

 

updateTweets.php

---

code to update all 150

---

 

2:

 

updateTweets.php?someId=1

----

code to update 1

+redirect to next

----

 

 

In example one after sometime i get the time error cause 60 second exceeded and the page still wan't done.

In example 2, it loads a new page before it hits the time error, that's what i meant with less time.

 

Sorry for my crappy explanation.

I'm doing my best.

Link to comment
https://forums.phpfreaks.com/topic/239371-too-many-redirects/#findComment-1229767
Share on other sites

As far as I understand He was using a for loop... His problem is that when using a normal for loop his script was taking too long and thus going over the maximum execution time allowed by PHP. He tried to get around this by doing 1 entry per page load, but this resulted in chrome telling him the page had too many redirects.

 

As far as your problem OP, if you have access to your PHP.ini, you could increase the maximum execution time. However, if you posted your code perhaps someone could give you pointers on making your code more efficient. I haven't used the twitter API personally, but seeing as its fairly widely used, I can't imagine that it in itself is so inefficient its causing really long execution times

Link to comment
https://forums.phpfreaks.com/topic/239371-too-many-redirects/#findComment-1229786
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.