0

I am sending a post to Wordpress 3.8 with XML RPC. Here is the raw XML being sent to wordpress:

<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
   <methodName>wp.newPost</methodName>
   <params>
      <param>
         <value>
            <int>0</int>
         </value>
      </param>
      <param>
         <value>
            <string>admin</string>
         </value>
      </param>
      <param>
         <value>
            <string>password</string>
         </value>
      </param>
      <param>
         <value>
            <struct>
               <member>
                  <name>post_status</name>
                  <value>
                     <string>publish</string>
                  </value>
               </member>
               <member>
                  <name>post_title</name>
                  <value>
                     <string>test 0.762719240039587</string>
                  </value>
               </member>
               <member>
                  <name>post_content</name>
                  <value>
                     <dateTime.iso8601>20140111T20:39:15</dateTime.iso8601>
                  </value>
               </member>
               <member>
                  <name>post_date</name>
                  <value>
                     <dateTime.iso8601>20140111T20:39:15</dateTime.iso8601>
                  </value>
               </member>
               <member>
                  <name>terms_names</name>
                  <value>
                     <struct>
                        <member>
                           <name>category</name>
                           <value>
                              <array>
                                 <data>
                                    <value>
                                       <string>test</string>
                                    </value>
                                 </data>
                              </array>
                           </value>
                        </member>
                     </struct>
                  </value>
               </member>
            </struct>
         </value>
      </param>
   </params>
</methodCall>

Seems ok. The Date is being sent with the correct UTC (the post was made at 14:39 Chicago time, -6 GMT) time and I get a post ID back (in this case 28062). Groovy.

Taking a look at it in phpMyAdmin the results go a bit weird.

phpMyAdmin Results

ID #28063 has the correct timestamp on post_date_gmt, but the parent (28062), has a date that is 12 hours out from the date that was sent. Double the correct GMT offset. What is going on here?

2
  • Is the post_type of that post an auto-draft?
    – Otto
    Commented Jan 11, 2014 at 21:22
  • @Otto the post_type is revision and the post_name is 28062-revision-v1. It's not an autosave Commented Jan 11, 2014 at 21:35

1 Answer 1

0

Alright. I think I cracked it.

<dateTime.iso8601>20140111T20:39:15</dateTime.iso8601>

Should be:

<dateTime.iso8601>20140111T20:39:15Z</dateTime.iso8601>

Looks like the toolkit I was using didn't quite implement iso8601 perfectly (or wordpress isn't - not sure). I'm using Node Wordpress and tracked down that it uses the module Node XML RPC to actually send the XML RPC. This seems to be where the wrong date formatting is occurring.

1
  • Ahh, yes. In the iso8601_to_datetime function, if the timezone is not specified (no "Z"), then it assumes that that is local time and will apply the gmt_offset value. Possibly the doubling is because it's getting applied again somewhere else. You could test this by using different offsets to see if it's always doubled.
    – Otto
    Commented Jan 11, 2014 at 23:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.