0

I am getting xmlrpc xml posted to my server and I want to catch the xml and store it in a text file for later processing.

This is what I have, but I just get a blank text file

$getXML = file_get_contents('php://input');
 $xml = new SimpleXMLElement($getXML);
 $text = $xml->Text;

 $today = date("Y-m-d");

 $randomnr = rand(100000, 999999);
 $datet = date("Ymd-H:i:s");
 $filename = "/var/www/".$datet."-".$randomnr.".txt";


 $fh = fopen($filename, 'w') or die("can't open file");
 fwrite($fh, $text);
 fclose($fh);

Can anyone see why I cam getting a blank text file?

2
  • fwrite() returns the number of bytes written, or FALSE on error. - Which value does it return in your case? What is var_dump($text);? Commented Apr 6, 2013 at 0:09
  • 1
    Are you sure $xml->Text; exist? What if you save $xml->asXML(); instead? (or the raw $getXML?) Commented Apr 6, 2013 at 0:16

1 Answer 1

0

I found This answer for your question

1)HTTP POST data is usually populated in $_POST, php://input will usually contain PUT data.

2)php://input cannot be opened/read when receiving a multipart/form-data POST, maybe that's what changed client-sided? – Wrikken Mar 28 at 20:01

file_get_contents('php://input') keeps returning empty

php://input returns empty

php://input returning empty string

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.