I have created an app and verified it.
I have retrieved the access_token and the linkedin_id.
I have managed to publish posts on linkedin.
After I share I get this message stdClass Object ( [id] => urn:li:share:6555444310316195840 )
The json looks like this:
$body_json='
{
"author": "urn:li:person:'.$linkedin_id.'",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text": "Share some url!"
},
"shareMediaCategory": "ARTICLE",
"media": [
{
"status": "READY",
"description": {
"text": "NEWS."
},
"originalUrl": "https://news.test.ce",
"title": {
"text": "TEST"
}
}
]
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "CONNECTIONS"
}
}';
The code is :
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.linkedin.com/v2/ugcPosts");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json',
"x-li-format" => "json",
'Authorization: Bearer '.$access_token));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$body_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
$result_decoded = json_decode($result);
I see the post if I go to notifications , but it's not visible on my company's page.
How can I make the post visible in my company page?
I have tried to replace in json_body, the author, with
"author": "urn:li:organization:'.$linkedin_id.'",
and the linkedin_id this case is the company id (previously I used my own linkedin_id)
But I get this error :
stdClass Object ( [serviceErrorCode] => 100 [message] => Field Value validation failed in REQUEST_BODY: Data Processing Exception while processing fields [/author] [status] => 403 )
I have all tried to call GET /organizations/org_id but I get this error
{"serviceErrorCode":100,"message":"Not enough permissions to access: GET /organizations/org_id","status":403}
BUT I am the admin of the company , I can access the admin page ...
How do I share on my own company page?