Happyr / LinkedIn-API-client

A library to connect with LinkedIn API. Perfect if you are looking for an API client or SDK for LinkedIn

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

ramsjared16 opened this issue · comments

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.