POST リクエストをリッスンする小さな PHP スクリプトがあります。私は常にxmlを期待しています。通常、私は xml リクエストを送信する側です。でも今日は受け取る側です。
$_POST をリッスンする単純なケースだと思いましたが、間違っている可能性があります。何も得られません。
xml を待機するスクリプトは次のとおりです。
<?php
if(isset($_POST)) {
mail("me@myemail.com","some title i want", print_r($_POST, true));
}else{
die("uh, what happened?");
}
?>
そして、これは私が別の場所から送信している単純な xml 文字列です。
<?php
$xml_data ='
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don\'t forget me this weekend!</body>
</note>
';
function sendXML2Server($URL,$XML){
$xml_data = trim($XML);
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
echo sendXML2Server('https://someurl.com/inboundxml.php',$xml_data)
?>
そして、これが私のメールで得たものです:
配列 ( )
私は配列を正しく操作していないと推測していますが、これには他に何か欠けているものがあるかもしれません。実際のxml文字列が返されることを期待しています。