[wp-trac] [WordPress Trac] #6612: Problems with setting XML-RPC date using metWeblog.newPost()
WordPress Trac
wp-trac at lists.automattic.com
Sat Aug 15 11:17:56 UTC 2009
#6612: Problems with setting XML-RPC date using metWeblog.newPost()
-------------------------------+--------------------------------------------
Reporter: Da_fonz | Owner: anonymous
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: XML-RPC | Version: 2.8.4
Severity: normal | Resolution: invalid
Keywords: reporter-feedback |
-------------------------------+--------------------------------------------
Changes (by effectivemarketing):
* status: reopened => closed
* resolution: => invalid
Comment:
Replying to [comment:7 westi]:
> Your request is incorrectly encoding the date as a <string></string> not
an <dateTime.iso8601></dateTime.iso8601> as it should be.
>
> If you encode your request correctly then it will work.
Hi,
Ok, understood.
The corrected code THAT WILL WORK is as follows:
{{{
<?php
include_once('wp-includes/class-IXR.php');
$url = 'http://www.yourdomain.com/xmlrpc.php';
$user = 'admin';
$pass = 'password';
$client = new IXR_Client($url);
$date = new IXR_Date('20090815T10:00:00');
$client->query('metaWeblog.newPost', 1, $user, $pass,
array('post_status' => 'draft',
'title' => 'Date Set Test Post',
'description' => 'Test Post',
'dateCreated' => $date), 1);
$res = $client->getResponse();
if ($res) {
print "Post #$res added successfully<br>\n";
} else {
print "Post not added<br>\n";
}
?>
}}}
My apologies - however the confusion arises from the Codex
([http://codex.wordpress.org/XML-RPC_wp]) which isn't very clear.
The codex states (for instance for wp.newPage) that the format for the
dateCreate parameter is:
{{{
datetime dateCreate
}}}
So when reading this there wasn't sufficient information to understand the
datetime itself had to be encapsulated in
{{{<dateTime.iso8601></dateTime.iso8601>}}} before it would work.
Also, there is very little documentation about the IXR_Client library
which makes it a bit more difficult to find the relevant information. I
guess I would have reached the correct conclusion earlier if I had built
the XML file from scratch rather than using the IXR_Client class.
Ticket can be closed; the above code works perfectly.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/6612#comment:8>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list