API を使用して LinkedIn からコメントを取得しようとしていますが、次のエラーが表示されます。
The remote server returned an error: (401) Unauthorized.
[WebException: The remote server returned an error: (401) Unauthorized.]
System.Net.HttpWebRequest.GetResponse() +6442408
Demo.WebForm1.Page_Load(Object sender, EventArgs e) in y:\Demo\Demo\WebForm1.aspx.cs:38
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
私はこのコードを書いた、Page_Load で私は要求を与えた
protected void Page_Load(object sender, EventArgs e) {
string strURL = "http://api.linkedin.com/v1/groups/67657/posts?order=recency&category=discussion";
System.Net.HttpWebRequest objWebRequest = null;
System.Net.HttpWebResponse objWebResponse = null;
System.IO.StreamReader streamReader = null;
string strHTML = null;
System.Net.ServicePointManager.ServerCertificateValidationCallback =
delegate(object s,
System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Security.Cryptography.X509Certificates.X509Chain chain,
System.Net.Security.SslPolicyErrors sslPolicyErrors)
{ return true; };
objWebRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(strURL);
objWebRequest.Method = "GET";
objWebRequest.Credentials = System.Net.CredentialCache.DefaultCredentials;
//Here I'm getting an error
objWebResponse = (System.Net.HttpWebResponse)objWebRequest.GetResponse();
streamReader = new System.IO.StreamReader(objWebResponse.GetResponseStream());
strHTML = streamReader.ReadToEnd();
streamReader.Close();
objWebResponse.Close();
objWebRequest.Abort();
Response.ContentType = "text/xml";
Response.Write(strHTML);
Response.End();
}