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: 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 #148

Open
ramsjared16 opened this issue Jan 10, 2018 · 1 comment

Comments

@ramsjared16
Copy link

ramsjared16 commented Jan 10, 2018

Q A
Bug? not sure
New Feature? no
Are you using composer? yes
Version ??? The most current I'm assuming. I installed via composer Jan 9, 2018.

Actual Behavior

Getting the following error when I load a test page that I created:
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

Expected Behavior

What is the behavior you expect?
I had copied the code below that is provided in the "Usage" section of this project, so I expected to just say "hello (first name)" - since I had already logged in

$linkedIn=new Happyr\LinkedIn\LinkedIn('client_id', 'client_secret');

if ($linkedIn->isAuthenticated()) {
//we know that the user is authenticated now. Start query the API
$user=$linkedIn->get('v1/people/~:(firstName,lastName)');
echo "Welcome ".$user['firstName'];

exit();

} elseif ($linkedIn->hasError()) {
echo "User canceled the login.";
exit();
}

//if not authenticated
$url = $linkedIn->getLoginUrl();
echo "Login with LinkedIn";

Steps to Reproduce

I was able to make the login feature from the code above work once. But then I got the above error message. I then re-installed this api client in a new directory, went through the install steps, but am getting the error message still.

It was working, then I added the code from here, and that was when it stopped working: https://github.com/Happyr/LinkedIn-API-client/blob/master/tests/AccessTokenTest.php

That was when I tried a fresh install in a new directory, and of course did not include the code from "AccessTokenTest.php", but the same error message persists even in a new directory.

@SuperToma
Copy link

I think this can fix your problem :
https://github.com/Happyr/LinkedIn-API-client/pull/162/files

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

No branches or pull requests

2 participants