We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20682
    • 31 Posts
    I am having an issue with $HTTP_RAW_POST_DATA within modx. I have created a XML-RPC server using IXR library. The server works perfectly *outside* of modx, but within modx, the $http raw post data variable is unavailable to the IXR class. I have provided for the php 5.2.2 bug by using this code:
    if (!isset($HTTP_RAW_POST_DATA)){
        $HTTP_RAW_POST_DATA = file_get_contents('php://input');
    }
    .

    As I said, the server works perfectly outside of modx. I have tried to GLOBAL the variable everywhere - which does not work.

    The snippet (for pingbacks), I have created is called within a blank template, text/xml. Perhaps the content type is wrong? The stand alone (outside of modx) was just a php file.

    Does anyone have any suggestions, ideas or notions about this strange problem. Maybe it’s something I don’t know about modx??

    Thanks for any help
    Sheri
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Keep in mind that all MODx snippets are run through the PHP eval() function (this is no longer the case in the 0.9.7 codebase). It might have some bearing on why your server isn’t working as expected.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 20682
        • 31 Posts
        Thank you Susan. I am still stumped. Creating a global out of $HTTP_RAW_POST_DATA does nothing, although it does work outside of modx. The code that requires the raw post data is located within a class. Does this have any bearing on variable access?
          • 22303 MODX Staff
          • 10,725 Posts
            • 20682
            • 31 Posts
            Thank you OpenGeek,

            This is called externally from the php class:

            if (!isset($HTTP_RAW_POST_DATA)){
                $HTTP_RAW_POST_DATA = file_get_contents('php://input');
            }


            I’ll try to put it within the class to see if that makes a difference.

              • 22303 MODX Staff
              • 10,725 Posts
              The point was, set that ini setting or make sure the MODx document serving this code is setting the proper content-type header required for this variable to be populated. By default, it will not be the proper content-type, but text/html, as most pages served are just HTML.