Open SteveTalbot opened 10 years ago
The same problem arises also with getRequestToken. I guess the problem it that getAccessToken/getRequestToken are forwarded to the Consumer which isn't forwarded any http_client_options/http_client.
Even setting http_client manually is ignored.
The issue is blocking on my project as the class Socket fails because sslverifypeer = true and I'm not able to disable it.
I ended up setting the httpClient globally for OAuth using OAuth::setHttpClient()
$config = array(
'adapter' => 'Zend\Http\Client\Adapter\Curl',
'curloptions' => array(
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false
),
);
$httpClient = new HttpClient(null,$config);
OAuth::setHttpClient($httpClient);
The same $httpClient
is given to Twitter()
as http_client option
Does anyone have a more elegant solution?
@giulioprinaricotti Looks like a neat approach
@SteveTalbot thank you. Only drawback I see is that you have to repeat it every time it is needed and setting something global is always a source of problems.
This repository has been closed and moved to laminas/laminas-twitter; a new issue has been opened at https://github.com/laminas/laminas-twitter/issues/2.
When a Twitter object is first instantiated, an HTTP client is created, using the http_client_options specified in the array passed into the constructor. So for example, if you want to use curl as your HTTP adapter, you can do something like this:
When getAccessToken() is called, the HTTP client is replaced and the http_client_options are not honoured. This means the default stream adapter will be used instead of curl.
The problem seems to be on line 219 of ZendService\Twitter\Twitter.php, but I've been trying for ages and can't find an elegant solution: