Skip to main content
Sep 22, 2010 4:52 PM UTC
Question

xml.send() sending blank data?

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 is closed to new replies. Start a new post to keep the conversation going.

    3 replies

    Sep 22, 2010 5:18 PM UTC

    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");

    Translate
    Sep 22, 2010 5:22 PM UTC

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

    Translate
    Sep 22, 2010 5:24 PM UTC

    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

    Translate