Skip to content

Commit

Permalink
Fix posting to Linked.in
Browse files Browse the repository at this point in the history
  • Loading branch information
engram-design committed Jan 10, 2020
1 parent cc13f73 commit ef5acfc
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions src/providers/LinkedIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ public function getDefaultOauthScope(): array
{
return [
'r_basicprofile',
// 'r_liteprofile',
'r_liteprofile',
'r_emailaddress',
'w_share',
'w_member_social',
// 'w_organization_social',
];
}

Expand Down Expand Up @@ -69,20 +70,29 @@ public function sendPost($account, $content)

$personURN = $this->getProfile($client)['id'];

$response = $client->post('ugcPosts', [
$thumbnails = [];

if (isset($content['picture']) && $content['picture']) {
$thumbnails[] = [
'resolvedUrl' => $content['picture'],
];
}

$response = $client->post('shares', [
'json' => [
'author' => 'urn:li:person:' . $personURN,
'lifecycleState' => 'PUBLISHED',
'specificContent' => [
'com.linkedin.ugc.ShareContent' => [
'shareCommentary' => [
'text' => $content['message'],
],
'shareMediaCategory' => 'NONE',
'content' => [
'contentEntities' => [
[
'entityLocation' => $content['url'],
'thumbnails' => $thumbnails,
]
],
'title' => $content['title'],
],
'visibility' => [
'com.linkedin.ugc.MemberNetworkVisibility' => 'PUBLIC',
'owner' => 'urn:li:person:' . $personURN,
'subject' => $content['title'],
'text' => [
'text' => $content['message'],
],
],
]);
Expand Down

0 comments on commit ef5acfc

Please sign in to comment.