通过C#& amp进入wordpress博客WordPressSharp

时间:2015-04-11 21:09:19

标签: c# wordpress xml-rpc wordpresssharp

我正在使用WordPressSharp并尝试将内容添加到我的wordpress博客中。

我在添加内容方面遇到了麻烦。

Helper.WordpressConfigurations.postToWordpress(1, "testing", "content description");

这是我的帖子方法

public static Post setPost(int postType, string title, string content)
    {
      string type = postType == 1 ? "post" : "page";
      int categoryId = 0;
      switch ("".ToLowerInvariant())
      {
        case "arrow": categoryId = 4; break;
        default: categoryId = 0; break;
      }
      return new Post
      {
        PostType = "post", // "post" or "page"
        Title = title,
        Content = content,
        PublishDateTime = DateTime.Now,
        Status = "publish"//, // "draft" or "publish",
        //Terms = terms
      };
    }

在WordpressClient.cs中有例外>

enter image description here

我的完整代码http://paste.ubuntu.com/10793675/

1 个答案:

答案 0 :(得分:0)

WordPressSharp依赖于 xml-rpc.net 版本3.0.0,它还不是一个稳定的版本,似乎有bug。请尝试使用版本2.5.0。

  1. 下载wordpresssharp和xml-rcp.net 2.5.0的源代码。
  2. 从wordpresssharp项目中删除对3.0.0程序集的引用,并添加对2.5.0的引用。
  3. 它适用于我的情况,我希望它对你有所帮助。