C# Post/Add BlogPost to wordpress


using CookComputing.XmlRpc;

namespace BlogSubmitterFXApp.WorkWithAPI
{
    public struct blogInfo
    {
        public string title;
        public string description;
    }

    public interface IgetCatList
    {
        [CookComputing.XmlRpc.XmlRpcMethod("metaWeblog.newPost")]
        string NewPage(int blogId, string strUserName, string strPassword, blogInfo content, int publish);
    }

    public static class WordPress
    {
        public static bool NewPost(string strUserName, string strPassword, string blogurl ,blogInfo bi)
        {


            blogInfo newBlogPost = default(blogInfo);

            newBlogPost.title = bi.title;
            newBlogPost.description = bi.description;

            IgetCatList categories = (IgetCatList)XmlRpcProxyGen.Create(typeof(IgetCatList));
            XmlRpcClientProtocol clientProtocol = (XmlRpcClientProtocol)categories;

            //For example clientProtocol.Url = "http://msnetdeveloper.wordpress.com/xmlrpc.php";
            clientProtocol.Url = blogurl;

            string result = null;
            result = "";

            try
            {
                result = categories.NewPage(1, strUserName, strPassword, newBlogPost, 1);
                return false;
            }
            catch 
            {
                return true;
            }
        }
    }
}

1 comment:

Note: only a member of this blog may post a comment.