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?

4

1 回答 1

0

我为你的问题找到了这个答案

1)HTTP POST 数据通常填充在 $_POST 中,php://input 通常会包含 PUT 数据。

2) php://input 在接收到 multipart/form-data POST 时无法打开/读取,也许这就是客户端改变的原因?– Wrikken 3 月 28 日 20:01

file_get_contents('php://input') 一直返回空

php://input 返回空

php://input 返回空字符串

于 2013-04-04T15:18:47.350 回答