Get the num followers with linkedin API v2

Viewed 4663

The num followers of linkedin API is not working anymore. We used to use https://api.linkedin.com/v1/companies/11543/num-followers, but it responds with the error listed below.

{
  "errorCode": 0,
  "message": "This resource is no longer available under v1 APIs",
  "requestId": "EUBVUH7QTU",
  "status": 410,
  "timestamp": 1561391381048
}

We need to get this number with v2 but it seems to have been deprecated in v2 according to these docs.

The totalFollowerCounts field is deprecated and will stop being included in responses after January 31, 2019.

Is there a way to get the number of followers using V2 of LinkedIn's API?

3 Answers

David.

I think you already know that V1 Api version has been deprecated, and you have to migrate all your code to the new V2 endpoints.

Assuming your APP already has access to the V2 version, you can get the follower statistics using this V2 endpoint.

If you need to get the followers statistics by segments, you can use this other endpoint, where you can pass many arguments (region, language, seniority...)

You can access the followers using the following url https://www.linkedin.com/pages-extensions/FollowCompany?id={companyId}&counter=bottom

Replace companyId with your companyId.

This will result in a webpage that can be easily parsed. result

Example in code:

            var client = new HttpClient();
            var request = new HttpRequestMessage(HttpMethod.Get, "https://www.linkedin.com/pages-extensions/FollowCompany?id={companyId}&counter=bottom");

            var response = await client.SendAsync(request);
            response.EnsureSuccessStatusCode();


            var payload = await response.Content.ReadAsStringAsync();
            var doc = new HtmlDocument();
            doc.LoadHtml(payload);

            var node = doc.DocumentNode.SelectNodes("//div[contains(@class, 'follower-count')]");

            var f = node.FirstOrDefault().InnerText;

source: https://taras.codes/blog/linkedin-organization-follower-count/

It seems that your app doesn't have full access to the V2 version of the Linkedin API, because I assume your token can manage the company with ID 11543, right?

In this case, you have to apply to the Marketing Developer Platform, accesible from the Linkedin Apps Console, because the access to V2 version is restricted, and not all apps that apply get this permission. enter image description here

Related