J7mbo / twitter-api-php

The simplest PHP Wrapper for Twitter API v1.1 calls
MIT License
1.82k stars 802 forks source link

Ability to decrease the CURLOPT_TIMEOUT value #160

Closed bondt closed 8 years ago

bondt commented 8 years ago

Hi,

I would like to propose an option where we can overwrite the default value for CURLOPT_TIMEOUT in performRequest, as seen here: https://github.com/J7mbo/twitter-api-php/blob/master/TwitterAPIExchange.php#L282

How say you?

J7mbo commented 8 years ago

Yep, this is a fair point, I agree. Currently we're appending, this needs to be changed :)

glenscott commented 8 years ago

You can overwrite the default value of CURLOPT_TIMEOUT by passing it in as part of the second argument to performRequest. For example:

$req->performRequest(true, array( 'CURLOPT_TIMEOUT' => 2 ) );
lesterchan commented 8 years ago

The Pull Request is here https://github.com/J7mbo/twitter-api-php/pull/178 =)

@glenscott that does't work. That is because the array is concatenated and hence the array on the left will take precedence over the argument passed in into performRequest(). By changing it to array_merge, I am able to overwrite it because now, the argument passed into performRequest() takes precedence.

bondt commented 8 years ago

@lesterchan, awesome, thanks!

micperr commented 8 years ago

@lesterchan array_merge is not good here because it will reindex cURL's numeric options keys so they will not work for cURL anymore

J7mbo commented 8 years ago

204 fixes this. It's in develop now and will merge soon. Thanks!