0
我试图写一个程序在C#中,我卡住了。该程序假设通过xmlrpc在wordpress上创建一个帖子。我可以成功创建帖子,但是在为帖子创建自定义字段时遇到问题。所以当我打开创建的帖子时,自定义字段永远不会存在。我希望你们中的一些大师可以帮助我为我停留3天,现在无法弄清楚做什么,感觉绝对无助:(C#XMLRPC自定义字段
继承人一些代码:
public struct customField
{
public string key;
public string value;
}
public struct newPost
{
public string[] categories;
public string title;
public string description;
public string mt_excerpt;
public customField[] cf;
}
public interface IcreatePost
{
[CookComputing.XmlRpc.XmlRpcMethod("metaWeblog.newPost")]
string NewPost(int blogId, string strUserName,
string strPassword, newPost content, int publish);
}
继承人如何设置值为对象称为
customField newCustomField2 = default(customField);
newCustomField2.key = "some data";
newCustomField2.value = "some data";
newPost newBlogPost = default(newPost);
newBlogPost.title = "Some Title";
newBlogPost.description = "Some Content";
newBlogPost.cf = new customField[] { newCustomField2 };
createPost(newBlogPost);
功能:
public void createPost(newPost np)
{
string postid;
icp = (IcreatePost)XmlRpcProxyGen.Create(typeof(IcreatePost));
clientProtocol = (XmlRpcClientProtocol)icp;
clientProtocol.Url = "http://127.0.0.1/xmlrpc.php";
try
{
postid = icp.NewPost(1, "admin", "1234", np, 1);
}
catch (Exception ex)
{
MessageBox.Show("createPost ERROR ->"+ ex.Message);
}
}
太感谢你了!问题解决了:) – user1047463