-
Notifications
You must be signed in to change notification settings - Fork 116
Avoid getting the "Syntax error" from json_decode #29
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
Conversation
Avoid getting the "Syntax error" from json_decode when when LinkedIn API returns an empty response.
@mnajafzadeh could you provide an example when you did run into such issue?
Hi @zoonman
An example can be, when you try to post a comment on a LinkedIn company page like:
$response = $client->post("companies/".$company_id."/updates/key=".$updateKey."/update-comments-as-company/", ['comment' => $message]);
This kind of requests have not any response if it is successful.
Thank you.
albertleao
commented
Jan 29, 2019
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see in composer.json
that we require PHP >= 5.6. So, I want to suggest change this line to return []
. But this is not obligatory, just my small tip.
Hi @zoonman
An example can be, when you try to post a comment on a LinkedIn company page like:
$response = $client->post("companies/".$company_id."/updates/key=".$updateKey."/update-comments-as-company/", ['comment' => $message]);
This kind of requests have not any response if it is successful.
Thank you.
This is not the correct fix for your issue.
The UGC Post is created with a 201 Created response and the response header X-RestLi-Id contains the ugcPost ID.
Linkedin does give response but it's in the header not body. We should parse the response correctly.
reichert-lucas
commented
Apr 6, 2021
Hi
In my case, the problem was resolved by changing the API Root URL to version 2.
$this->client = new Client(
env('LINKEDIN_CLIENT_ID'),
env('LINKEDIN_CLIENT_SECRET')
);
$this->client->setApiRoot('https://api.linkedin.com/v2/');
$this->client->setRedirectUrl(env('LINKEDIN_CALLBACK'));
Uh oh!
There was an error while loading. Please reload this page.
Avoid getting the "Syntax error" from json_decode when LinkedIn API returns an empty response.