Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error With Guzzle #133

Open
stephenvicino opened this issue Dec 6, 2016 · 23 comments · May be fixed by #134
Open

Error With Guzzle #133

stephenvicino opened this issue Dec 6, 2016 · 23 comments · May be fixed by #134

Comments

@stephenvicino
Copy link

stephenvicino commented Dec 6, 2016

Q A
Bug? Yes
New Feature? no
Are you using composer? yes
Version 1

Actual Behavior

Fatal error: Call to undefined method GuzzleHttp\Client::sendAsync()

Expected Behavior

Oauth

Steps to Reproduce

$linkedIn->setHttpClient(new \Http\Adapter\Guzzle6\Client());
 $linkedIn->setHttpMessageFactory(new Http\Message\MessageFactory\GuzzleMessageFactory());

When I click the login URL, I get the error: Fatal error: Call to undefined method GuzzleHttp\Client::sendAsync()

@Nyholm
Copy link
Member

Nyholm commented Dec 6, 2016

Interesting.

I've tried to reproduce this but failed. What does your composer.json look like?
Can you provide a stack trace?
Who is trying to call GuzzleHttp\Client::sendAsync()?

@stephenvicino
Copy link
Author

Full Error Message:

Fatal error: Call to undefined method GuzzleHttp\Client::sendAsync() in /var/www/includes/vendor/php-http/guzzle6-adapter/src/Client.php on line 64

My Composer.json:
"league/csv": "~7.1",
"aws/aws-sdk-php": "^3.0",
"mandrill/mandrill": "1.0.",
"mixpanel/mixpanel-php" : "2.
",
"stripe/stripe-php": "3.",
"abraham/twitteroauth": "^0.6.2",
"pusher/pusher-php-server": "^2.2",
"smalot/pdfparser": "^0.9.25",
"eventviva/php-image-resize": "1.5.
",
"hashids/hashids": "^1.0",
"spatie/pdf-to-image": "^1.1",
"nojimage/twitter-text-php": "^1.1",
"twilio/sdk": "^4.10",
"lusitanian/oauth": "^0.8.9",
"thomaswelton/gravatarlib": "^0.1.0",
"vinelab/rss": "^1.0",
"php-ffmpeg/php-ffmpeg": "^0.6.1",
"php-http/curl-client": "^1.6",
"guzzlehttp/psr7": "^1.3",
"php-http/message": "^1.4",
"happyr/linkedin-api-client": "^1.0",
"php-http/guzzle6-adapter": "^1.1"

This is the call that is failing: $user=$linkedIn->get('v1/people/~:(firstName,lastName)');

It generates the getLoginUrl() fine.

@Nyholm
Copy link
Member

Nyholm commented Dec 6, 2016

That is very strange. It looks alright, I tried to reproduce but I still cant..

Can you show me the output of:

composer show -i

(If you want to be more private it may be okey by:)

composer show -i | grep guzzle  

@stephenvicino
Copy link
Author

You are using the deprecated option "installed". Only installed packages are shown by default now. The --all option can be used to show all packages.
guzzlehttp/guzzle 6.2.2 Guzzle is a PHP HTTP client library
guzzlehttp/promises 1.3.0 Guzzle promises library
guzzlehttp/psr7 1.3.1 PSR-7 message implementation
php-http/guzzle6-adapter v1.1.1 Guzzle 6 HTTP Adapter

@Nyholm
Copy link
Member

Nyholm commented Dec 6, 2016

It looks like you got all the proper versions and everything is fine.. Do you use the composer autoloader?

Do you have the same issues when you use the curl client?

@stephenvicino
Copy link
Author

I am unsure if this is related, but somehow I am getting a new error message:

Catchable fatal error: Method Happyr\LinkedIn\AccessToken::__toString() must return a string value in /vendor/happyr/linkedin-api-client/src/LinkedIn.php on line 111

I tracked it down to this I believe: [__PHP_Incomplete_Class_Name] => Happyr\LinkedIn\AccessToken

@Nyholm
Copy link
Member

Nyholm commented Dec 6, 2016

That is unrelated. But also strange.

What PHP version do you run?

@stephenvicino
Copy link
Author

PHP Version 5.5.9-1ubuntu4.20

Ok, I got past the Guzzle error by just removing everything but your project and dependencies. I will try to narrow it down to see what package is causing it, however I am stuck on the other error now.

@stephenvicino
Copy link
Author

Ok, this combination works:
"guzzlehttp/guzzle": "^6.2",
"php-http/curl-client": "^1.6",
"guzzlehttp/psr7": "^1.3",
"php-http/message": "^1.4",
"happyr/linkedin-api-client": "^1.0"

@Nyholm
Copy link
Member

Nyholm commented Dec 6, 2016

That's what you had before, right? #133 (comment)

@stephenvicino
Copy link
Author

Minus the php-http/guzzle6-adapter v1.1.1 Guzzle 6 HTTP Adapter

@Nyholm
Copy link
Member

Nyholm commented Dec 6, 2016

Okey, so now you are using the Curl client, right?

@stephenvicino
Copy link
Author

Yes, not setting the http client

@stephenvicino
Copy link
Author

I reinstalled the guzzle6 adapter and am using Guzzle now,

However I can't get past the

Method Happyr\LinkedIn\AccessToken::__toString() must return a string value

error now.

@Nyholm
Copy link
Member

Nyholm commented Dec 6, 2016

Can you debug this line: https://github.com/Happyr/LinkedIn-API-client/blob/master/src/AccessToken.php#L42

And tell me what $this->token is before we print it?

@stephenvicino
Copy link
Author

Sure thing;

$this->token has the following value
__PHP_Incomplete_Class Object
(
[__PHP_Incomplete_Class_Name] => Happyr\LinkedIn\AccessToken
[token:Happyr\LinkedIn\AccessToken:private] => I REMOVED THE ACCESS TOKEN
[expiresAt:Happyr\LinkedIn\AccessToken:private] => DateTime Object
(
[date] => 2017-02-04 10:48:59
[timezone_type] => 3
[timezone] => America/New_York
)

)

@Nyholm
Copy link
Member

Nyholm commented Dec 6, 2016

Can you try this branch to see if I fixed your problems: https://github.com/Happyr/LinkedIn-API-client/tree/issue-133

(You may have to clear your browser cookies)

composer require happyr/linkedin-api-client:dev-issue-133

@stephenvicino
Copy link
Author

stephenvicino commented Dec 6, 2016

It worked on first load, then I refreshed the page and got the same error message bout toString

@Nyholm
Copy link
Member

Nyholm commented Dec 7, 2016

Thank you for helping me debug this. I've never been able to reproduce this issue. I've push another change to that branch. Would you mind giving it another try?

@Nyholm Nyholm linked a pull request Dec 7, 2016 that will close this issue
2 tasks
@stephenvicino
Copy link
Author

stephenvicino commented Dec 7, 2016

Still getting the error after call back,

Whats the correct way to get the access token after authenticating LinkedIn?

@Nyholm
Copy link
Member

Nyholm commented Dec 7, 2016

That is strange... Can you debug how that value comes in to $this->token in the first place?

@stephenvicino
Copy link
Author

So it works the first time, but its gets stored in the session as an incomplete Object.

@Nyholm
Copy link
Member

Nyholm commented Dec 7, 2016

Okey, I've pushed a change now where I serialize the access token before we store it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants