Skip to main content
September 22, 2010
Question

xml.send() sending blank data?

  • September 22, 2010
  • 1 reply
  • 552 views

I am attempting to send XML data to a PHP script from my server-side app using the following code:

    var my_xml = new XML("<highscore><name>Ernie</name><score>13045</score></highscore>");
    my_xml.contentType = "text/xml";
    my_xml.send("http://www.server.com/temp/fms_post.php");

I am logging anything that the outside server receives at $_REQUEST, $_POST, $_GET. I can see that my server-side app is reaching out to the external server, but the data is always blank. Am I doing something wrong here?

    This topic has been closed for replies.

    1 reply

    September 22, 2010

    Been a while since I've done this method using PHP, but I'm pretty sure what you want is

    $somevar = file_get_contents("php://input");

    September 22, 2010

    Yes! That did it. Although, I have never seen "php://input" before, will have to look into that...

    September 22, 2010

    It's for reading the raw data of the request. Since the XML is sent as raw data and not assigned to post/get vars, you need to read the request body to get the data.

    http://php.net/manual/en/wrappers.php.php