Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


How to Implement an API Request TimeOut (PHP) ? #73

oosswwaalldd opened this Issue · 6 comments

2 participants


Hi Matt,

I am working on a web page project that get and lists an authenticated user's followers, but I have encountered once in a while that the request made:

$tmhOAuth->request('GET', $tmhOAuth->url('1/followers/ids'), array('cursor' => -1)); [note that I use themattharris php lib]

takes too long to get back from Twitter and therefore and "error_log" file is created indicating that the file has exeeded the maximun exec time. So my question is:

Is there any way to "measure" or implement and timeout in the API request so I can validate this time-failed request?

I would appreciate your help as always!

@themattharris themattharris was assigned

hey oosswwaalldd,

the library sets a connect timeout of 30 seconds and a curl timeout of 10 seconds. you can change these yourself in the initialisation of the tmhOAuth object. for example:

$tmhOAuth = new tmhOAuth(array(
  'consumer_key'    => 'YOUR_CONSUMER_KEY',
  'consumer_secret' => 'YOUR_CONSUMER_SECRET',
  'user_token'      => 'A_USER_TOKEN',
  'user_secret'     => 'A_USER_SECRET',
  'curl_connecttimeout' => 30,
  'curl_timeout'     => 10,  

if you are having trouble you most likely you will want to change the curl_connecttimeout to something lower like 5 (5 seconds)


Thanks! I will try that!

Another thing.. are you going to change the libs to adapt it to the new Twitter API changes? if so, is there a date?



let me know how the timeout change worksout for you.
for the recent changes to the Twitter API there aren't any updates necessary for the tmhOAuth.php script. it takes a developer/user defined URL at runtime so any new urls are string replacements in your implementation.

i'll get some API 1.1 examples put together and added to to show how to do it though.

was there something in particular that you thought would require an update to the library?


No, I was kind of worried because my Twitter web app (with a lot of clients using it) relies 100% upon your PHP lib, I am calm now knowing that I dont have to update the lib itself but only some changes on the strings when calling the lib object. I am gonna proceed to read all the new API 1.1 documentation to verify those changes.

This is not a php lib related question but is there a deadline for the Twitter API 1.0 to stop functioning? what is my window to adapt to the 1.1 version?

Thanks for the answers and support.


so long as you stay current with my PHP lib versions (follow @tmhOAuth -- to know about updates) things should be fine.

if anything does break on api 1.1 ticket me on github and i'll get it fixed up.

for the sunset of Twitter API v1.0, in it was said that there would be six months to migrate from when API v1.1 is released. in it says Starting March 5th, 2013, the 1.0 endpoints will no longer be available.


Thanks Matt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.