2012/07/11

c#, xmlrpc 워드프레스 글 쓰기 예제 (wp.newPost)

using CookComputing.XmlRpc;
public class XmlRpc
{
    public struct blogInfo
    {
        public string post_title;
        public string post_content;
        public DateTime post_date;
        public string post_status;
        public string comment_status;
    }

    // http://codex.wordpress.org/XML-RPC_WordPress_API/Posts
    [XmlRpcUrl(http://yeonpil.org/xmlrpc.php)]
    public interface IWP
    {
        [XmlRpcMethod("wp.newPost")]
        string NewPage(int blogId, string strUserName, 
                                 string strPassword, blogInfo content);
    }
}
public class Wordpress : XmlRpc
{
    public void WritePost(string _title, string _content, 
                                         DateTime _date, string _status)
    {
        blogInfo _post = default(blogInfo);
        _post.post_title = _title;
        _post.post_content = _content;
        _post.post_date= _date;
        _post.post_status = _status;
        _post.comment_status = "open";

        IWP proxy = (IWP)XmlRpcProxyGen.Create(typeof(IWP));
        string result = proxy.NewPage(blogid, "id", "pwd", _post);

        Console.WriteLine("postID: " + result);
    }
}
 



댓글 없음:

댓글 쓰기

가장 많이 본 글