1

過去 1 週間、LinkedIn に投稿コメントを追加しようとしています

私はこのコードを書いた

    protected void Page_Load(object sender, EventArgs e)
    {
        string xmlContent = "<?xml version='1.0' encoding='UTF-8'?>";
        xmlContent += "<comment><text>Check out</text></comment>";
        byte[] databytes = Encoding.Default.GetBytes(xmlContent);

        var credentials = new Hammock.Authentication.OAuth.OAuthCredentials
        {
            Type = OAuthType.AccessToken,
            SignatureMethod = OAuthSignatureMethod.HmacSha1,
            ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
            ConsumerKey = "*********",
            ConsumerSecret = "*********",
            Token = "*********",
            TokenSecret = "*********",
            Version = "1.0"
        };

        var client = new Hammock.RestClient() { Authority = "http://api.linkedin.com/v1/posts" };
        var request = new Hammock.RestRequest() { Path = "/56787878/comments", Method = Hammock.Web.WebMethod.Post, Timeout = new TimeSpan(0, 0, 5), Credentials = credentials };
        request.AddHeader("Content-Type", "application/xml");
        client.AddParameter("","");
        client.AddPostContent(Encoding.UTF8.GetBytes(xmlContent));
        //request.AddPostContent(Encoding.UTF8.GetBytes(xmlContent));
        var response = client.Request(request);
        Response.Write(response.Content);
     }

以下の Xml 形式でエラーが発生します

 <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
 <error>  
 <status>400</status>
 <timestamp>1374494502579</timestamp>
 <request-id>QM4MYPEKJJ</request-id>  
 <error-code>0</error-code>
 <message>Couldn't parse message document: error: Unexpected end of file after null</message>\n</error>

誰もこのエラーを処理しますか? 前もって感謝します。

4

0 に答える 0