Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    May 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Receiving XML response in php script (encoding.com)

    Hi,
    I'm trying to utilize information in an XML response from encoding.com

    once encoding has finished converting a file, it sends and HTTP POST request to a php script for me. I'm having trouble accessing the POST info.

    have tried
    PHP Code:
    file_get_contents('php://input'); 
    but that didn't work for me.

    i've run the rest of my script accessing the info from a .xml file and it worked fine so my issue is just figuring out how to get the xml in the POST.

    Encoding.com api is here.

    Thanks!

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Have you tried the process encoding.com demonstrates in the sample PHP script?

    http://www.encoding.com/wdocs/SampleScripts#php

  • #3
    New to the CF scene
    Join Date
    May 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi, thanks for the response. I have used the sample script as a model for my initial request and that is working fine, I have no trouble capturing that initial response. The response I'm having trouble with is the response they send minutes or hours later when the video has been encoded.

    Maybe you're saying I can use the same method? curl? This is the part I'm confused on. I have RTFM, but it seems they don't address the what I'm trying to do, or they do and it's just not explicit and I'm not making the connection.

    Any other comments you have would be appreciated. Thanks!

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Yeah it seemed to be a little fuzzy on the website how to catch that, but if it's just a normal HTTP POST request, PHP will put the info in the $_POST array and you'll be able to create an XML object from the $_POST array. The POST request is sent to a specific script on your website I assume?

  • #5
    New to the CF scene
    Join Date
    May 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    okay, some progress! using:

    PHP Code:
    $response $_POST['xml']; 
    I'm getting this:

    Code:
    <?xml version="1.0"?>
    <result><mediaid>179962</mediaid><source>http://santamonica.s3.amazonaws.com/src/3c8797fe12a3</source><status>Finished</status><description></description><format><taskid>637094</taskid><output>flv</output><status>Finished</status><destination>http://santamonica.s3.amazonaws.com/enc/3c8797fe12a3.flv?acl=public-read</destination></format></result>
    I need to get the value enclosed in the source tags and eventually the destination tags.

    I'm trying:
    PHP Code:
    $response $_POST['xml'];
    $doc= new DOMDocument();
    $doc->loadXML($response);
    $sourceNode $doc->getElementsByTagName("source");
    $source $sourceNode->item(0)->nodeValue
    but this doesn't seem to be grabbing the source value.

    Can you see what I'm screwing up?

  • #6
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    I've never dealt with the DOM Document object but it looks pretty cool! I can see the example in the PHP manual you used as a template and it looks to me like you're doing everything right. So..

    Try print_r() on the objects in question to see if they are built the way we think they should be built.

  • #7
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by aaronrab View Post
    PHP Code:
    $response $_POST['xml'];
    $doc= new DOMDocument();
    $doc->loadXML($response);
    $sourceNode $doc->getElementsByTagName("source");
    $source $sourceNode->item(0)->nodeValue
    but this doesn't seem to be grabbing the source value.
    check if $doc, $sourceNod and $source are null or not, also check with $sourceNode->length if node list is empty or not.

    best regards

  • #8
    New to the CF scene
    Join Date
    May 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Went with a workaround

    Thanks to both of you for responding. I finally gave in and went with a workaround. Kind of irritates me, but at least the situation made one available.
    Thanks,
    Aaron


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •