Reputation: 430
I'm struggling with LinkedIn API and will appreciate any help.
What I need is to get latest articles that were posted or shared by my organization to than put them on our website.
What I have so far:
Than I use this function to make API calls:
function request_api( $url, $vars, $type = "POST", $headers = [] ){
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
if ( $type == "POST" ) {
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query( $vars ) );
}
if ( $headers ) {
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
}
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$server_output = curl_exec( $ch );
curl_close( $ch );
return $server_output;
}
When I make call to request_api( "https://api.linkedin.com/v2/me", [], "GET", $headers );
I get normal response - json encoded info (name, image etc.)
But requests to /organization
fail with 403
error.
I tried request_api( "https://api.linkedin.com/v2/organizations?q=vanityName&vanityName=my_organization_vanity_name", [], "GET", $headers );
and it return {"serviceErrorCode":100,"message":"Not enough permissions to access: GET-vanityName /organizations","status":403}
.
I'm not the admin in my_organization_vanity_name
so I don't know the organization id and according to docs I can't request from https://api.linkedin.com/v2/organizations/my_organization_id
I'd like to know if I for sure will get the company data with authenticated admin user using the code above.
And if so, how can I obtain the articles that were posted/shared on organization page?
Upvotes: 0
Views: 2209
Reputation: 26
I think you need the "rw_organization_admin" scope as well.
For this you need to request the "Marketing Developer Platform" product.
I checked this by using Postman.
Upvotes: 1