如何使用C#访问WordPress的xmlrpc.php

引用DLL:CookComputing.XmlRpcV2.DLL

核心代码:

using System;
using System.Windows.Forms;
using CookComputing.XmlRpc;

[XmlRpcUrl("http://www.dns.net/xmlrpc.php")]
public interface IXmlRpc: IXmlRpcProxy
{
    [XmlRpcMethod("demo.sayHello")]
    string sayHello();

    [XmlRpcMethod("demo.addTwoNumbers")]
    int addTwoNumbers(int a, int b);

    [XmlRpcMethod("wp.getPageList")]
    object wp_getPageList(params object[] args);
}

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            IXmlRpc ixp = XmlRpcProxyGen.Create<IXmlRpc>();
            ixp.XmlEncoding = new System.Text.UTF8Encoding();

            int blog_id = 0;
            string username = "***";
            string password = "***";

            object result = ixp.wp_getPageList(blog_id, username, password);
        }
    }
}

posted on 2010-02-26 11:00  Vengen  阅读(1779)  评论(0编辑  收藏  举报

导航