Joe Blogs 项目Bug:发布博客时无法设置分类

最近玩wordpress,利用xml-rpc写发布程序时,发现了两个好用的工具库:

xml-rpc.net:实现了xml-rpc的.net框架;

Joe Blogs:封装了wordpress api的.net库;

开发过程中发现,使用Joe Blogs发布博客时无法设置分类,对比live writer 发布博客时http包发现,wordpress设置分类使用的分类名,而不是分类Id;

OK,找到原因后,修改Joe Blogs源码:

1. 类 JoeBlogs.Post 修改为

using System;

namespace JoeBlogs
{
    public class Post
    {
        private int _postID;

        public Post()
        {
            DateCreated = DateTime
                .Now;
        }

        public int PostID { get { return _postID; } }

        public DateTime DateCreated { get; set; }
        public string Body { get; set; }
        public string Title { get; set; }
        //public int[] Categories { get; set; }
        public string[] Categories { get; set; }
        public string[] Tags { get; set; }

        public override string ToString()
        {
            return this.Body;
        }
    }
}

2. 结构体 JoeBlogs.XmlRpc.XmlRpcPost 修改为

using System;
using CookComputing.XmlRpc;

namespace JoeBlogs.XmlRpc
{
    /// <summary> 
    /// This struct represents the information about a post that could be returned by the 
    /// EditPost(), GetRecentPosts() and GetPost() methods. 
    /// </summary> 
    [XmlRpcMissingMapping(MappingAction.Ignore)]
    public struct XmlRpcPost
    {
        public DateTime dateCreated;
        public string description;
        public string title;
        public string postid;

        //public int[] categories;
        public string[] categories;

        public string[] mt_keywords;

        public override string ToString()
        {
            return this.description;
        }
    }
}
3. 创建文章时,将分类名传给文章的分类
Post post = new Post(); 
post.Title = title; 
post.Body = body; 
post.Categories = new string[] { category.Name };

一切搞定!

我在codeplex上发现也有人碰到相同问题,回复了解决方法,项目发起者说他已将项目转移到github project

转载于:https://my.oschina.net/u/577606/blog/62955

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值