tags:

views:

74

answers:

5

Hi I am trying to get a data feed from a vendor. I set up a page and gave them a URL and told them to httppost csv data.

right now my page just looks like this so I can see what the data looks like that I am getting:

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

mail('[email protected]','data feed from vendor',$feedData);

They said they sent me some test data, I checked my email and I got the email but it was blank. I am not sure if I did something wrong or they did.

What should be my next step to trouble shoot this?

Thanks!

A: 

check what kind of $feedData you're using and whether it conforms to the requirements. My guess is that it doesn't.

SilentGhost
A: 

http post data should be in $_POST['var'];

try this:

mail('[email protected]','data feed from vendor',var_export($_POST, true));
Karsten
Hi I tried this too, and had them try again. I got the email empty again. All they have is a URL and they are supposedly sending me a feed to the URL. I think they are doing a server to server post but I am having sort of a communication barrier with them. THANKS
John Isaacks
A: 

Are you uploading a file and reading it with php://input?, since php://input does not work with multipart/form-data

Ólafur Waage
A: 

You could also try to filter and read http packets via Wireshark, if you are hosting the receiving part yourself.

Karsten
+1  A: 

HTTP POST data should be present in $_POST. You should first check that this superglobal contains any data. If not, data are not being correctly POSTed to your URL.

You are right to test by having data emailed to yourself, however this can be problematic with non-string types. You need to be certain that $feedData is a string and contains data.

Examining the type and content of a variable is straightforward when combining var_dump() with output buffering. Try:

ob_start();
var_dump($_POST);
$testDump = ob_get_contents();
ob_end_clean();

mail('[email protected]', 'data feed from vendor', $testDump);

Testing process:

  1. POST anything to your URL and check that the resulting email contains the correct data.

    If the resulting email is not as you expect, the fault lies with your code. Work with the code until the test email contains what you expect given the data you POST.

  2. Ask the vendor to POST their data

    Examine the resulting email and see if it matches what you expect. If not, check with the vendor as to the nature of the data they are sending - perhaps your understanding or expectations are wrong. Repeat until you get the correct content in the test email.

From examining the content of the test email, you can determine the elements within $_POST that are relevant to your needs, extract them as necessary and continue development.

At the point when your test email does contain what you expect, note the $_POST contents such that you can construct an identical POST request which you can use when continuing development.

Jon Cram
Thank you very much for this very detailed answer, I will try it out!
John Isaacks