Open Gisleburt opened 10 years ago
I am having same problem, it looks like same issue as https://github.com/zendframework/zf2/issues/5478 after 5 months still open?
Yup, it's piss poor.
Yup, it's piss poor.
Awesome, did you just volunteer for writing a test/fix, @Gisleburt? :)
Haha, sorry, GitHub apparently doesn't like to mention that you're email replys will be put here, I didn't even notice it was from GitHub.
My poorly worded point stands though, this module doesn't work, the documentation is crazy wrong and it hasn't been fixed, or even looked at in 3 months. I did already fix one bug but this is beyond me. My solution: I stopped using ZF2.
@Gisleburt that's perfectly fine, just keep an eye at where you're replying :)
@Gisleburt the right method to call for Zend\Http\Client is send()
, not request()
, the documentation is outdated. Even with that, there's a problem due to zendframework/zf2#5478. I'm going to take care of that issue in the following days. I'm sorry for the inconvenient and for the long delay on that.
I don't think it's just documentation issue, try example from http://framework.zend.com/manual/2.2/en/modules/zendservice.twitter.html it fails because adapter is not set.
@machek Enrico specifically said as much:
the documentation is outdated. Even with that, there's a problem due to zendframework/zf2#5478.
@Gisleburt, @machek I was unable to reproduce the issue, I tried this example and it works fine. Can you check this code on your side? I suggest to execute a composer.phar update
before.
As you can see in the example, I used the send()
method, I used the array() structure for the POST params in setParameterPost()
, and I used the sslcapath
options for HTTPS (used by Twitter).
@ezimuel Here is simple test calling Twitter API - https://gist.github.com/machek/11385838 I have to specify in composer: "zendframework/zend-http": "2.2.3", then it works.
When code uses latest version 2.3.0 it dies on: PHP Fatal error: Call to a member function connect() on a non-object in \vendor\zendframework\zend-http\Zend\Http\Client.php on line 1358
I can't help myself but it look like a bug, if there is required extra step, I would say it should throw an Exception, not die.
Thanks
@machek The test code that you provided is for ZendService_Twitter
, here we are discussing about ZendOAuth
. Your issue seems to be related with zendframework/ZendService_Twitter#21. I will use this example to fix the Twitter component.
I'll leave this issue opened for a while, until someone will send me a test code to reproduce the problem for ZendOAuth
.
The best solution to all this that I've found so far, is to comment out lines 76-79 in ZendOAuth\Client. The base class method getAdapter() is being overriden, for what purpose I can't tell. If you want to accept this solution, I can submit a pull-request?
what i did to fix this is on ZendOAuth\Client getAdapter function i used parent::getAdapter() the Http\Client.php getAdapter function has a check if the adapter is set, so i think the same should apply on the ZendOAuth\Client.
@xyfantis you are absolutely right, calling the parent method solves the problem, but since it is in the vendor folder, not a solution. Looking at the repository, the fix is only on master, no stable release for a few months, I wonder why, but after adding "zendframework/zendoauth": "dev-master" to composer and updating, problem solved.
@ezimuel you are not able to reproduce the problem cos in the example we are explicitly calling the setAdapter method, but with the example on the documentation, only using the config array passed to the ZendService\Twitter\Twitter($options), that does not happen, so we end up having the error. On master, the getAdapter was removed and we use the parent one, that checks first if it is set, if not, grab from the configuration.
This repository has been closed and moved to laminas/laminas-oauth; a new issue has been opened at https://github.com/laminas/laminas-oauth/issues/6.
This might be a documentation issue, but you don't seem to be able to send requests using the access token.
From http://framework.zend.com/manual/2.0/en/modules/zendoauth.introduction.html
(It's also worth noting the difference between
$config
and$configuration
)However
\Zend\Http\Client
which is returned byZendOAuth\OAuth::getHttpClient
does not have a method calledrequest()
.I've also tried
send()
but this throws the error