SalmanAzmat / php-twitter

Automatically exported from code.google.com/p/php-twitter
0 stars 0 forks source link

Add cURL Timeout Option #48

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Wait for Twitter to go completely offline
2. Load any page using this class

What is the expected output? What do you see instead?
The entire web page hangs because this class is waiting on cURL to find and 
process Twitter's 
API.

What version of the product are you using? On what operating system?
php-twitter 1.1, RHEL 5, Apache 2, PHP 5.1.x

Please provide any additional information below.
I suggest you add a cURL timeout option so that the script with gracefully fail 
if Twitter is 
completely offline or under heavy load (like today). Just add this to around 
line 723:

        curl_setopt($ch, CURLOPT_TIMEOUT, 2);

A very short timeout, like 2 seconds, should be fine because a working Twitter 
connection would 
normally take milliseconds. This will prevent the rest of the page from timeout 
errors and 
hanging on load.

You could also add this line, but it may not be necessary because true is 
already the default:

        curl_setopt($ch, CURLOPT_FAILONERROR, true);

Original issue reported on code.google.com by noaht...@gmail.com on 6 Aug 2009 at 10:50