WordPress.org

Ready to get started?Download WordPress

Forums

xml-rpc question (15 posts)

  1. TBotNik
    Member
    Posted 3 years ago #

    All,

    Opened a thread at:

    http://en.forums.wordpress.com/topic/posting-file-to-parent-post-using-xml-rpc?replies=2#post-521020

    And they referred me here.

    Trying to use xml-rpc to post a 'page'. I think I said 'post' in the original article, but actually dealing with pages.

    The code I've written so far is:
    [Code moderated as per the Forum Rules. Please use the pastebin]

    I enabled both the:

    extension=php_curl.dll
    extension=php_xmlrpc.dll

    files in my php.ini

    and the code runs but error, giving invalid xml header error.

    This does not change whether the 'post_parent' line is in the code or not.

    My first rodeo with this so can use some help.

    Thanks!

    TBNK

  2. TBotNik
    Member
    Posted 3 years ago #

    All,

    Well found and downloaded the IXR_Library.php from:

    http://scripts.incutio.com/xmlrpc/

    Using that and the following got the upload working:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    But the upload is still going up as a parent page, not as subpage.

    Could use help with understanding and correcting this.

    TBNK

  3. Joseph Scott
    Member
    Posted 3 years ago #

    First, I'd recommend just using PHP XML-RPC library for communications. WordPress ships with the IXR library, I'd recommend it for PHP XML-RPC processing.

    Second, take a look at the raw XML being sent back and forth. Any obvious errors? Compare it to an existing client app that does work doing the same thing and see what the differences are.

  4. TBotNik
    Member
    Posted 3 years ago #

    J,

    Well first, since it is my first rodeo, I don't know what you are referring to, so links and resources would be helpful?

    Second how does one trap the "raw XML"?

    Thanks!

    TBNK

  5. TBotNik
    Member
    Posted 3 years ago #

    All,

    On some of my commands I keep getting this error:

    An error occurred - -32700:parse error. not well formed

    Any ideas what is wrong?

    TBNK

  6. TBotNik
    Member
    Posted 3 years ago #

    All,

    Appears this is a "Correct Formatting" issue.

    Ah but what I found is this code resolves, when I feed my source to this function:

    function xml_entities($text, $charset = 'Windows-1252'){
          $text = htmlentities($text, ENT_COMPAT, $charset, false); // Encode html chars
          $arr_xml_special_char = array (""","&","'",
          				     "<",">");
          $arr_xml_special_char_regex = "(?";                       // Build the regex
          foreach($arr_xml_special_char as $key => $value){
             $arr_xml_special_char_regex .= "(?!$value)";
          }
          $arr_xml_special_char_regex .= ")";
          $pattern = "/$arr_xml_special_char_regex&(".
          		 "[a-zA-Z0-9]+;)/";                             // Scan for non XML
          $replacement = '&${1}';                               // Replace non XML
          return preg_replace($pattern, $replacement, $text);
       }  // end function

    and I can even fix with this abbreviated function of:

    function fix_xml ($text, $charset = 'Windows-1252'){
          $text = htmlentities($text, ENT_COMPAT, $charset, false); // Encode html chars
          //$text = htmlspecialchars($text, ENT_COMPAT, $charset, false); // Encode html chars
          return $text;
       }  // end function

    I tried fixing it with just the "htmlspecialchars" but still get the errors and when the code/context from this is submitted to WordPress all the html formatting is lost, and it must be maintained.

    Appears I am looking only to convert specific HTML codes to their "&xxx;" equivalents. Any ideas on which codes actually need converting to meet the XML formatting rules, especially for WP?

    Thanks!

    TBNK

  7. TBotNik
    Member
    Posted 3 years ago #

    OK,

    Tried this

    function fix_xml ($text, $charset = 'Windows-1252'){
          $text = urlencode($text); // Encode html chars
          //$text = htmlentities($text, ENT_COMPAT, $charset, false); // Encode html chars
          //$text = htmlspecialchars($text, ENT_COMPAT, $charset, false); // Encode html chars
          return $text;
       }  // end function

    and got worse.

    So what I'm thinking is comment out my first line in the first funtion of:
    $text = htmlentities($text, ENT_COMPAT, $charset, false); // Encode html chars
    and work at tweaking the REGEX so this goes through correctly, especially since the "&pound" is not found in the existing REGEX string and this seems to be the main source of contention.

    All feedback on this appreciated.

    Thanks!

    TBNK

  8. TBotNik
    Member
    Posted 3 years ago #

    All,

    OK! After trying several more things it is appearant that XML requires all HTML character to be converted to character reps of the same and WordPress must contain something in the XML-RPC that converts the encoded HTML characters back to regular HTML, as Scribefire works fine dumping an HTML page into WordPress.

    It must be some option that I need in my upload string, so the decoding is enabled. But what is that code. I'm not finding it in my searches of the manuals. Guess I do not have right keyword sequence.

    TBNK

  9. TBotNik
    Member
    Posted 3 years ago #

    Joseph,

    Found you have a solution of sorts at:

    http://wordpress.org/extend/plugins/libxml2-fix/

    Also another fix suggested is at:

    http://www.w3schools.com/xml/xml_cdata.asp

    using the CDATA encoding.

    Now just need a nice clean function(s) to test both and see which is best.

    Thanks!

    TBNK

  10. TBotNik
    Member
    Posted 3 years ago #

    Joseph,

    Tried your fix and still get the wrong thing.

    Look at this link please:

    http://waelinc.com/seo-%E2%80%93-articles/smo-social-media-optimization-company-for-the-city-of-addison-tx/

    You see the HTML tags are still encrypted as "<tagname>" so not being interpreted and formatting. In the edit mode, within WordPress, there are two options, a.) Visual, b.) HTML (upper right tabs) and the visual is coming out like the text should read in the HTML.

    Not quite sure how to use your fix, of the upgrade that is suppose to fix all this, but need my text to convert back to HTML as that is my source file(s).

    Thanks!

    TBNK

  11. TBotNik
    Member
    Posted 3 years ago #

    All,

    Source text file for this is:
    [Code moderated as per the Forum Rules. Please use the pastebin]

    So WP has to have a setting that causes "html_entity_decode()" to be called to allow the tags to revert back to the original HTML.

    I've been searching for that option, as I'm sure the WP programmers did not overlook it, but not finding it so far.

    If you know this option, please chime in!

    Thanks!

    TBNK

  12. TBotNik
    Member
    Posted 3 years ago #

    Joseph,

    Saw you work and I think you can help. Please look over the code at:

    http://pastebin.com/pSYxsB5B

    and let me know what is wrong. I think either wrong hook or wrong invocation action. Let me know.

    Thanks!

    TBNK

  13. status4
    Member
    Posted 3 years ago #

    Hey tbotnik, I´ve got the same problem. Did you found a solution? Thanks a lot.

    Status4

  14. TBotNik
    Member
    Posted 3 years ago #

    Status4,

    No had to get off this project for a while, others more pressing. Went to IRC for WordPress and the experts there were clueless on this also.

    Boils down to getting the "right method" and the "right handler" and not knowing any WP internals nor philosophy, I would just have to read up on all them and try them one by one, till it works, which I currently have no time for.

    If you can get someone with WP internals knowledge to chime in on this should be able to fix in minutes.

    Thanks!

    TBNK

  15. TBotNik
    Member
    Posted 3 years ago #

    All,

    Well we had a WP expert Randy Hoyt speak at our Dallas PHP users group, so thinking about this again and reaching out to see who in our PHP community will assist in this effort.

    I still contend that since PHP encoding is a rudimentary function, that should have meant that encode and decode for it are included in the WP baseline fuctionality.

    Thanks!

    TBNK

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.