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);
            }
        }

I get the error:
"Server returned a fault exception: [-32700] parse error. not well formed"
...regardless

OK, I had to change from my Wordpress(.org) site to my Wordpress(.com) site to resolve the -32700 error.

I added the custom field code, but nothing appeared in the post or the management console.

Maybe the theme I'm using does not show custom fields.

...still checking...
I'm also looking at this: http://codex.wordpress.org/Using_Custom_Fields

Displaying Custom Fields
With a Custom Field added to the post, it's time to display your books and mood to the world. To display the Custom Fields for each post, use the the_meta() template tag. The tag must be put within The Loop in order to work. Many people add the_meta() template tag to the end of their post or in their Post Meta Data Section.

OK, I had to change from my Wordpress(.org) site to my Wordpress(.com) site to resolve the -32700 error.

I added the custom field code, but nothing appeared in the post or the management console.

Maybe the theme I'm using does not show custom fields.

...still checking...
I'm also looking at this: http://codex.wordpress.org/Using_Custom_Fields

its not the theme, while editing post, top right corner you will see screen options, click that and select custom fields.

The problem is that the c# app fails to insert custom fields:(

Wow.

how i can set tag with this code ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.