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

Avoid getting the "Syntax error" from json_decode #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mnajafzadeh
Copy link

@mnajafzadeh mnajafzadeh commented Nov 7, 2018

Avoid getting the "Syntax error" from json_decode when LinkedIn API returns an empty response.

Avoid getting the "Syntax error" from json_decode when when LinkedIn API returns an empty response.
@zoonman
Copy link
Owner

zoonman commented Nov 7, 2018

@mnajafzadeh could you provide an example when you did run into such issue?

@mnajafzadeh
Copy link
Author

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
Copy link

👍

true
);
}
return array();
Copy link
Contributor

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.

@soisme
Copy link

soisme commented Feb 1, 2019

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.

@reichert-lucas
Copy link

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'));

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 this pull request may close these issues.

6 participants