如何查找给定articleId的特定linkedin文章的所有评论?

时间:2015-01-02 19:16:55

标签: c# api linkedin

我发布了LinkedIn article,我正在尝试检索此特定文章的评论。我通过右键单击注释按钮并复制链接地址来获取 articleId 。我得 aritcleId = 7434836657526032700。我应该使用GET http://api.linkedin.com/v1/posts/{post-id}/comments {post-id}与articleId相同吗?

成功 AuthorizationLinkGet 调用后,下面是我的代码。

string oauth_token = Request.QueryString["oauth_token"];
string oauth_verifier = Request.QueryString["oauth_verifier"];
if (oauth_token != null && oauth_verifier != null)
{
    Application["oauth_token"] = oauth_token;
    Application["oauth_verifier"] = oauth_verifier;

    //get access token
    _oauth.Token = oauth_token;
    _oauth.TokenSecret = Application["reuqestTokenSecret"].ToString();
    _oauth.Verifier = oauth_verifier;

    _oauth.AccessTokenGet(oauth_token);

    sLinkedInCommentsURL = "http://api.linkedin.com/v1/posts/7434836657526032700/comments";

    string response = _oauth.APIWebRequest("GET", sLinkedInCommentsURL, null);
    lblMessage.Text = response;
}

我收到以下错误:

Server Error in '/dreamplaybook' Application.

The remote server returned an error: (403) Forbidden.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Net.WebException: The remote server returned an error: (403) Forbidden.

Source Error: 


Line 433:            finally
Line 434:            {
Line 435:                webRequest.GetResponse().GetResponseStream().Close();
Line 436:                responseReader.Close();
Line 437:                responseReader = null;

Source File: c:\inetpub\calendias\dreamplaybook\App_Code\oAuthLinkedIn.cs    Line: 435 

Stack Trace: 


[WebException: The remote server returned an error: (403) Forbidden.]
   System.Net.HttpWebRequest.GetResponse() +6538872
   oAuthLinkedIn.WebResponseGet(HttpWebRequest webRequest) in c:\inetpub\calendias\dreamplaybook\App_Code\oAuthLinkedIn.cs:435
   oAuthLinkedIn.APIWebRequest(String method, String url, String postData) in c:\inetpub\calendias\dreamplaybook\App_Code\oAuthLinkedIn.cs:357
   adposter.Page_Load(Object sender, EventArgs e) in c:\inetpub\calendias\dreamplaybook\adposter.aspx.cs:282
   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

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34237

1 个答案:

答案 0 :(得分:1)

文章ID与帖子ID不是同一个字段,因此这就是您收到错误的原因。 API不允许您从出版物中获取评论。