Solved

XML postback from yousendit get variables and return response OK

Posted on 2010-11-19
17
649 Views
Last Modified: 2012-05-10
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:

xml_response->
<ysi-response xmlns=\'http://www.yousendit.com/xml/ns/\' >
<interface name=\'UploadStatus\'>
<ibox_info>
  <request_param>request_param>
ibox_info>
<batch_info>
  <batch_id>batch_id>
  <batch_name>batch_name>
  <client_IP>client_IP>
  <status>status>
  <batch_download_link>batch_download_link>
batch_info>
<file_info>
  <file_name>file_name>
  <file_size>file_size>
  <date_uploaded>date_uploaded>
  <file_download_link>file_download_link>
file_info>
interface>
ysi-response>

thanks...
0
Comment
Question by:freshwaterwest
  • 9
  • 4
  • 2
  • +1
17 Comments
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
0
 

Author Comment

by:freshwaterwest
Comment Utility
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
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
0
 

Author Comment

by:freshwaterwest
Comment Utility
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?
0
 

Author Comment

by:freshwaterwest
Comment Utility
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.

0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
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
0
 

Author Comment

by:freshwaterwest
Comment Utility
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

Phil
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
10-4.  I'll be around!
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:freshwaterwest
Comment Utility
I'm hoping to get stuck in with this again in the next day or so, just keeping the question open.. ; )
0
 

Author Comment

by:freshwaterwest
Comment Utility
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
Phil
0
 

Author Comment

by:freshwaterwest
Comment Utility
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');
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
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.
0
 

Author Comment

by:freshwaterwest
Comment Utility
Thanks Ray - so should I be able to simply use the following at the end of my script?:

<?php

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

Open in new window

0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
Comment Utility
Umm, not sure about that without seeing a lot more code.  Check the man page here:
http://php.net/manual/en/function.header.php

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...
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ob_start();

/* DO STUFF */

// CAPTURE THE BUFFERS
$output = ob_get_clean();

/*  AND TEST TO SEE IF EVERYTHING IS OK */

// SEND THE HEADER
header('HTTP/1.1 200 OK'); 

// DO WHATEVER YOU MIGHT NEED WITH $output
return $output;

Open in new window

0
 

Author Comment

by:freshwaterwest
Comment Utility
I see what you mean, that's great I'll give it a shot tonight

thanks Ray
0
 
LVL 16

Expert Comment

by:CWS (haripriya)
Comment Utility
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

A few customers have recently asked my thoughts on Password Managers.  As Security is a big part of our industry I was initially very hesitant and sceptical about giving a program all of my secret passwords.  But as I was getting asked about them mo…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now