Unable to get companies for LinkedIn API version V2
Asked Answered
O

2

7

I use the Zoonman LinkedIn API PHP SDK to get information about companies an authenticated user is an admin of, using this bit of code:

$profileCompany = $client->get(
    'companies',
    ['is-company-admin' => "true"]
);

This worked perfectly with API version V1. However, with V2, it gives a 400 not found error. I came across this: Organization Lookup API but not exactly sure if this is the right endpoint, as there is no API call to exactly do what the above code snippet does.

Could someone please help with the right endpoint?

Opinion answered 19/12, 2018 at 8:8 Comment(0)
P
2

From the docs

Please note the following changes when migrating your app from v1 of the LinkedIn API Platform:

Company Pages and Showcase Pages are now surfaced as Organization and Brand resources, respectively. Both resources are considered "Organizational Entities," and share common fields and similarities in how data is accessed.

URNs uniquely identify organizational entities, and can be generated with existing company or showcase ids:

Organization: urn:li:organization:{company id}

The above code make call the rest api "List all companies that the member is an administrator of". It does not seems have a direct equivalent API available in v2.

Organisation lookup/search APIs seems nearest alternative.

Hope this helps.

Pneumectomy answered 30/12, 2018 at 19:16 Comment(0)
T
9

If you have the access token from the user this is possible in v2 of the LinkedIn API. See:

https://developer.linkedin.com/docs/guide/v2/organizations/organization-lookup-api#acls

The full URL for the basic request would be:

https://api.linkedin.com/v2/organizationalEntityAcls?q=roleAssignee&role=ADMINISTRATOR&state=APPROVED&projection=(*,elements*(*,organizationalTarget~(*)))

With paging:

https://api.linkedin.com/v2/organizationalEntityAcls?q=roleAssignee&role=ADMINISTRATOR&state=APPROVED&projection=(*,elements*(*,organizationalTarget~(*)))&start=[...]&count=[...]

And you probably want the organization logo urls as well:

https://api.linkedin.com/v2/organizationalEntityAcls?q=roleAssignee&role=ADMINISTRATOR&state=APPROVED&projection=(*,elements*(*,organizationalTarget~(*,logoV2(original~:playableStreams,cropped~:playableStreams,cropInfo))))&start=[...]&count=[...]

For linkedin-api-php-client see also: https://github.com/zoonman/linkedin-api-php-client/issues/31

Treasonable answered 17/1, 2019 at 10:0 Comment(5)
we should apply for partner program to get the permission for manage company pages api.Did you get the permissions? How long it will take?Danaus
@augustinejenin We did get permission to join the Marketing Developer Program. Since this was two years ago I don't remember how long it took. Guess it was a matter of days or weeks.Treasonable
Thank you so much for this! For what it's worth, it looks like the docs for this have moved to learn.microsoft.com/en-us/linkedin/marketing/integrations/…Buck
Also, I didn't like the idea of getting so much extra data - we only needed the id and the localizedName. So, I simplified the projection, resulting in a URL of https://api.linkedin.com/v2/organizationalEntityAcls?q=roleAssignee&role=ADMINISTRATOR&state=APPROVED&projection=(elements*(organizationalTarget~(id,localizedName)))&start=[...]&count=[...]Buck
@Buck How to access the elements of organizationalTarget~ ?Endlong
P
2

From the docs

Please note the following changes when migrating your app from v1 of the LinkedIn API Platform:

Company Pages and Showcase Pages are now surfaced as Organization and Brand resources, respectively. Both resources are considered "Organizational Entities," and share common fields and similarities in how data is accessed.

URNs uniquely identify organizational entities, and can be generated with existing company or showcase ids:

Organization: urn:li:organization:{company id}

The above code make call the rest api "List all companies that the member is an administrator of". It does not seems have a direct equivalent API available in v2.

Organisation lookup/search APIs seems nearest alternative.

Hope this helps.

Pneumectomy answered 30/12, 2018 at 19:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.