API:https://api.linkedin.com/v2/me?projection=(id,firstName,lastName)
应用许可:r_basicprofile,r_emailaddress,w_share
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
string requesturl = "https://api.linkedin.com/v2/me?projection=(id,firstName,lastName)";
HttpWebRequest webRequest = System.Net.WebRequest.Create(requesturl) as HttpWebRequest;
webRequest.Method = "GET";
webRequest.Host = "api.linkedin.com";
//webRequest.ContentType = "application/x-www-form-urlencoded";
//webRequest.Connection = "Keep-Alive";
webRequest.Headers.Add("Authorization", "Bearer " + accessToken);
//Stream dataStream = webRequest.GetRequestStream();
//String postData = String.Empty;
//byte[] postArray = Encoding.ASCII.GetBytes(postData);
//dataStream.Write(postArray, 0, postArray.Length);
//dataStream.Close();
WebResponse response = webRequest.GetResponse();
Stream dataStream = response.GetResponseStream();
StreamReader responseReader = new StreamReader(dataStream);
String returnVal = responseReader.ReadToEnd().ToString();
答案 0 :(得分:0)
如果您使用的是V2 API,但您没有获得使用r_basicprofile的权限,则可以申请使用r_basicprofile进入linkedin的权限
或将r_liteprofile + r_emailaddress用于V2 (还要检查您的应用程序中是否存在r_liteprofile权限)
r_liteprofile用于firstName,lastName,profilePicture,id r_emailaddress获取电子邮件地址