Get a company followers count on LinkedIn

Viewed 2208

I'm trying to get the number of followers of a company on Linked in. I use this code:

HttpWebRequest request = WebRequest.Create("http://api.linkedin.com/v1/companies/?id=SomeCompanyID:(num-followers)") as HttpWebRequest;
request.Method = "Get";
request.Credentials = new NetworkCredential("MyAppClientID", "MyAppClientSecret");

using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)   // I'm getting "(401) Unauthorized" exception at this line.
{
    StreamReader reader = new StreamReader(response.GetResponseStream());

    string result = reader.ReadToEnd();
    System.IO.File.WriteAllText(@"WriteText.txt", result);
    Console.WriteLine(reader.ReadToEnd());
}

I'm not sure about my syntax and the way I provide credentials, but I don't know how to do so correctly, and documentation is not clear at this point.

Your help is appreciated.

1 Answers
Related