XML postback from yousendit get variables and return response OK

I need to receive the XML values from yousendit and then return OK but not sure where to start.

here's an example of what might get posted back from yousendit:

<ysi-response xmlns=\'http://www.yousendit.com/xml/ns/\' >
<interface name=\'UploadStatus\'>

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

freshwaterwestAuthor Commented:
Hi thanks for the link - some of the links within that question may help me with the parsing of xml, but what I really need to understand is how YouSendIt sends the xml back to my chosen page and how I then access the values
They give the example xml above, but how would that get posted, would it be in the form of: mypageforpostback.php?variable1=xxx&variable2=xxxx&variable3=xxxxx or in some array variable in a $_POST sort of format.

Basically what I'm saying is do I get the variables with $_POST for instance or maybe I get the array by this method and then have to parse the xml?

I'm really stuck as to where to get started..

many thanks
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

freshwaterwestAuthor Commented:
thanks leakim, but I really don't get the basics of what I need to do, I don't know where to start.

YouSendIt's example xml above is:
"example of server postback to your web server using HTTP Post format"

how can it be posted as xml?
freshwaterwestAuthor Commented:
This is what I've found in the YouSendIt Documentation:

¿After a user uploads the file, YouSendIt is able to post a set of values to your web server. This notification can be in XML or HTTP post format and will contain all the parameters that are passed in via the iFrame source along with the following information:
      •      batch_id = The unique ID to identify the files that were uploaded to our system.
      •      batch_name = Name of the batch (if user uploads a single file it will be name of the file itself or "YYYY-MM-DD-upload" if the user uploads multiple files).
      •      client_IP = IP address of the client who is sending the file.
      •      status = Status of the upload transaction. ("OK" for successful upload, "Failed" for failed uploads)
      •      file_name = Name of the file
      •      file_size = Size of the corresponding file
      •      Custom form values that are passed to the SiteDrop source code
Note: Your server must also be configured to return a page response of "OK" to signal you have received the postback successfully.

Ray PaseurCommented:
The example in the question does not make sense - it is not valid XML.  But that aside, you need some kind of asynchronous script on your server to receive the notification.  This is similar to the PayPal IPN.  It gets started by a GET or POST request from YouSendIt.  Presumably somewhere you will be able to tell YouSendIt the URL of this script.

The information your script will receive from YouSendIt may arrive in the $_GET or $_POST variable.  
The information your script will return to YouSendIt needs to include a "header 200."

You might want to use output buffering in your script, so you can use var-dump() to print out the GET and POST arrays.  Then you can capture the output buffer and email it to yourself.  That might seem a little clunky, but it's a useful way of getting output from asynchronous scripts.

If you understand everything I have written here, good luck.  If you do not, you probably want to hire a developer right now rather than waste your time trying to cut your teeth on this project - it's highly data-dependent and it's therefore got a huge number of things that can be confusing and frustrating.

Regards, ~Ray
freshwaterwestAuthor Commented:
Hi Ray, thanks for your reply - particularly helpful and informative. Sorry for the delayed reply, I've had a couple of late nights on a project so catching up.
I am fine with handling $_GET and $_POST in php - not so confident in javascript although I have used AJAX at a basic level so understand the principles - I'll have a bash over the next few days.

I guess I need to start by trying to test if I'm getting any $_GET or $_POST first. I've used output buffering once before to get around a "headers already sent" issue - ob_start() / ob_end_flush()

many thanks - I'll let you know how I get on as soon as poss

Ray PaseurCommented:
10-4.  I'll be around!
freshwaterwestAuthor Commented:
I'm hoping to get stuck in with this again in the next day or so, just keeping the question open.. ; )
freshwaterwestAuthor Commented:
Spent a lot of hours looking for examples online and tried a few things unsuccessfully, but I'm confused as to the structure of what I need to do, I need to understand the following:

- Firstly, (in the yousendit login account area) I provide a url to send the notification to but I'm not clear on whether this should be a html page which uses AJAX to then get this into another php page for further processing, or maybe I should just use one php page as the url.

- I can choose either • XML or • HTML Post, not really sure which will work best (I had chosen HTML Post hoping I could get the $_POST in php and avoid any XML complications / nodes etc which I'm less familiar with).

- I then need to return '200' ok message but could this be from the php (such as a header) or should it be from AJAX?

I think what is confusing me most is that normally AJAX is for updating something on the html page without re-loading or another page, but in this case we don't even see the page or need to return anything in html.

if you're around Ray, I'd really appreciate a little further clarification.
many thanks
freshwaterwestAuthor Commented:
I've stumbled across a related solution which may be pointing me in the right direction on this. Looks as though I should be able to use php file for it all.

I need to get back onto it and spend a bit more time to suss it out, but the only thing I expect will be the issue is how to post back the 200 header but looks like I need to use:

header('HTTP/1.1 200 OK');
Ray PaseurCommented:
Yes, that PHP command will send a header.  It is a law of HTTP that all headers must come before and be complete before there is any browser output.
freshwaterwestAuthor Commented:
Thanks Ray - so should I be able to simply use the following at the end of my script?:


// if we are happy with the variables and collected everything...
$output = header('HTTP/1.1 200 OK'); 
return $output;

Open in new window

Ray PaseurCommented:
Umm, not sure about that without seeing a lot more code.  Check the man page here:

Here is the general principle I follow with these sorts of things.

I use error_reporting(E_ALL) and ini_set('display_errors', TRUE) to be certain that I will get any error messages.
I use ob_start() to collect any messages in the output buffer so that I do not produce any browser output.
If everything is OK, I send the header.  (The header() function does not produce an output string that you can capture).

Maybe something more like this code snippet...
ini_set('display_errors', TRUE);

/* DO STUFF */

$output = ob_get_clean();


header('HTTP/1.1 200 OK'); 

return $output;

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
freshwaterwestAuthor Commented:
I see what you mean, that's great I'll give it a shot tonight

thanks Ray
CWS (haripriya)Commented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTTP Protocol

From novice to tech pro — start learning today.