linkedin-api-php-client
linkedin-api-php-client copied to clipboard
Avoid getting the "Syntax error" from json_decode
Avoid getting the "Syntax error" from json_decode 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.
👍
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.
https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/ugc-post-api
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.
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'));