Forums

Please help/Getting Date (10 posts)

  1. wordpresshelp111
    Member
    Posted 2 years ago #

    Hi,

    Please help with this. I am trying to use the XMLRPC to create a post, but cannot figure out how to pass a "dateCreated".

    I.e.,

    $content['date_created_gmt'] = date("Ydm");
    or
    $content['postDate'] = date("Ydm");
    $client->query('metaWebLog.newPost'...etc,etc)

    Basically, if I try executing that, I get this error (it is calling the xmlrpc.php installed by default in wordpress)

    "An error occured - 32700: parse error, not well formed"

    Any help would be GREATLY appreciated.

    Thanks!

  2. Joseph Scott
    Member
    Posted 2 years ago #

    Hard to tell exactly what the parse error was without seeing the raw XML, but a few things to note:

    - Highly recommend using the date_created_gmt field, which is by definition always GMT.
    - Remember that date fields are <dateTime.iso8601> (http://www.xmlrpc.com/spec)
    - The method name is metaWeblog.newPost (note the character case)

  3. wordpresshelp111
    Member
    Posted 2 years ago #

    Ok...

    How do I format the date field correctly then?

    I am trying to use:

    $content["date_created_gmt"]='2010-08-08 00:00:00'

    as a test, and it doesn't work. I have tried sticking a 'gmdate(...)' in front of that, still doesn't work.

    All my other fields (so far) work ok if I make changes, so no idea about this. I have tried "manually" making a iso8601 string, but that doesn't work either.

    Is there some 'special' wordpress way of formatting a date? As it is, I am having to manually rewrite this via SQL...

  4. Joseph Scott
    Member
    Posted 2 years ago #

    If you are using the IXR XML-RPC library (http://scripts.incutio.com/xmlrpc/), which is the one that WordPress ships with and uses, then you'll need to call IXR_Date class. Something like this:

    $content['date_created_gmt'] = new IXR_Date( $post_date_time );

    This allows will make the contents of that field use the dateTime.iso8601 XML-RPC data type.

  5. asechrest
    Member
    Posted 2 years ago #

    Totally off-topic comment. I read the title of this post as "please help getting a date." Thought I had wandered into an internet dating forum. =D

    Ok, carry on.

  6. wordpresshelp111
    Member
    Posted 2 years ago #

    Hi j. scott,

    Thanks!! That did the trick... How did you figure that out/know about it? Have you just done a lot of xmlrpc work? (I tried searching the wordpress docs, probably spent about 4-5 hours just to find *one* line of code :P)

    Where would you recommend further reading? (for anything xmlrpc related, but helping with wordpress?)

    Thanks very much! :)

  7. Joseph Scott
    Member
    Posted 2 years ago #

    I do a fair bit of XML-RPC work on WP. There's an email list:

    http://lists.automattic.com/mailman/listinfo/wp-xmlrpc

    Which is good to join if you are going to be doing WP XML-RPC (or AtomPub) work. If xmlrpc.com comes back again there was a fair bit of content on there (seems to be gone/down right now). I believe there are a few books around as well.

  8. attuk
    Member
    Posted 1 year ago #

    Hi Scott,
    Would IXR XML-RPC library the best to use for xmlrpc ?
    I am struggling to encode
    dateCreated in ISO in php using date("c") etc, I am thinking of using a library to make life easier.
    BTW, I read your reply on http://wordpress.org/support/topic/330597
    Thanks for any advice.

  9. Joseph Scott
    Member
    Posted 1 year ago #

    I like the IXR library.

    For date fields, make sure you are setting the field as a date type in the XML-RPC request.

  10. attuk
    Member
    Posted 1 year ago #

    Thanks I am using IXR now and it's much easier !

Topic Closed

This topic has been closed to new replies.

About this Topic