Im trying to to write a program in C# and I'm stuck. The program suppose to create a post on wordpress via xmlrpc. I can create the post successfully but I have problems creating custom fields for the post. So when I open created post, custom fields are never there. I hope some of you gurus can help me as I am stuck for 3 days now and cant figure out what to do, feel absolutely helpless:(
Heres some code:
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);
}
Heres how I set values for the object
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);
Function called:
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);
}
}