$postdata = file_get_contents("php://input");$textXML = urldecode($postdata);
"... Wir posten das XML nicht in einem HTML form. In unserem Fall ist das XML im http request (encoded als binary data) inkluiert ..."
<?phpwird die GET-Variable korrekt angezeigt, die SERVER-Variable CONTENT_LENGTH=9407 deutet darauf hin, dass die Daten übertragen wurden aber die POST-Variable ist leer.
foreach($_GET as $x => $y){echo $x.'='.$y.'<br/>';}
foreach($_POST as $x => $y){echo $x.'='.$y.'<br/>';}
foreach($_SERVER as $x => $y){echo $x.'='.$y.'<br/>';}
?>
header('Content-Type: text/xml; charset=ISO-8859-1'); oder header('Content-Type: text/xml; charset=utf-8');haben nichts gebracht.request.send(null);in einer Datei.
var content = request.responseXML;
Wir posten das XML nicht in einer HTML form. In unserem Fall ist das XML im http request (encoded als binary sdata) inkluiert ...
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');das XML nur teilweise an, mitrequest.setRequestHeader('Content-Type', 'text/xml');ist die POST-Variable leer.<?php
define ("NL", "\n");
$empfaenger = 'empfaenger01.php?ref=TestGetVariable';
$text = '';
$text .= '<?xml version="1.0" encoding="ISO-8859-1"?>'.NL;
$text .= '<email date="2011-08-03">'.NL;
$text .= ' <header atr="Attribut1" atr2="Attribut2">'.NL;
$text .= ' <from lang="de">Absender</from>'.NL;
$text .= ' <to>Empfänger</to>'.NL;
$text .= ' <subject>Test</subject>'.NL;
$text .= ' </header>'.NL;
$text .= ' <body>Hallo Welt</body>'.NL;
$text .= '</email>'.NL;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Test: Sender mit Formular</title>
</head>
<body>
<form action="<?php echo $empfaenger; ?>" method="post">
<p>xml-Text<br>
<textarea id="email" name="xml_text" cols="100" rows="9"><?php echo $text; ?></textarea>
</p>
<input type="submit">
</form>
</body>
</html>
<?php
define ("NL", "\n");
$strDatum = date_format(date_create(), "YmdHis");
$filename = $strDatum.'_test.txt';
setValues('GET-Variable');
$dump = print_r($_GET, true);
setValues($dump);
setValues('POST-Variable');
$dump = print_r($_POST, true);
setValues($dump);
setValues('SERVER-Variable');
$dump = print_r($_SERVER, true);
setValues($dump);
setValues('$_REQUEST-Variable');
$dump = print_r($_REQUEST, true);
setValues($dump);
/*
setValues('SESSION-Variable');
$dump = print_r($_SESSION, true);
setValues($dump);
setValues('COOKIE-Variable');
$dump = print_r($_COOKIE, true);
setValues($dump);
setValues('FILES-Variable');
$dump = print_r($_FILES, true);
setValues($dump);
setValues('ENV-Variable');
$dump = print_r($_ENV, true);
setValues($dump);
*/
function setValues($text){
global $filename;
if ($loghandle = fopen($filename, "ab")){
if (!fwrite($loghandle, $text.NL)) echo "Kann in die Textdatei $filename nicht schreiben";
}
else echo "Kann die Textdatei $filename nicht öffnen";
}
?>
<?php
define ("NL", "\n");
$empfaenger = 'empfaenger02.php?ref=TestGetVariable';
$text = '';
$text .= '<?xml version="1.0" encoding="ISO-8859-1"?>'.NL;
$text .= '<email date="2011-08-03">'.NL;
$text .= ' <header atr="Attribut1" atr2="Attribut2">'.NL;
$text .= ' <from lang="de">Absender</from>'.NL;
$text .= ' <to>Empfänger</to>'.NL;
$text .= ' <subject>Test</subject>'.NL;
$text .= ' </header>'.NL;
$text .= ' <body>Hallo Welt</body>'.NL;
$text .= '</email>'.NL;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Test: Sender mit XMLHttpRequest</title>
<script type="text/javascript">
<!--
var request = false;
function setRequest() {
// Request erzeugen
request = new XMLHttpRequest(); // Mozilla, Safari, Opera
if (request) {
var value = document.getElementById('email').innerHTML;
request.open('post', "<?php echo $empfaenger; ?>", true);
// Requestheader senden
//request.setRequestHeader('Content-Type', 'text/xml');
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
// Request senden
alert(value);
request.send(value);
// Request auswerten
}
}
//-->
</script>
</head>
<body>
<p>xml-Text<br>
<textarea id="email" name="xml_text" cols="100" rows="9"><?php echo $text; ?></textarea>
</p>
<a href="javascript:setRequest()">Versenden</a>
</body>
</html>
<?php
header('Content-Type: text/xml; charset=ISO-8859-1');
//header('Content-Type: text/xml; charset=utf-8');
//header('Content-Type: text/plain; charset=utf-8');
//header('Content-Type: text/plain; charset=ISO-8859-1');
//header('Content-Type: 'application/x-www-form-urlencoded; charset=utf-8');
//header('Content-Type: 'application/x-www-form-urlencoded; charset=ISO-8859-1');
header('Cache-Control: must-revalidate, pre-check=0, no-store, no-cache, max-age=0, post-check=0'); // wegen IE
define ("NL", "\n");
$strDatum = date_format(date_create(), "YmdHis");
$filename = $strDatum.'_test.txt';
setValues('GET-Variable');
$dump = print_r($_GET, true);
setValues($dump);
setValues('POST-Variable');
$dump = print_r($_POST, true);
setValues($dump);
setValues('SERVER-Variable');
$dump = print_r($_SERVER, true);
setValues($dump);
setValues('$_REQUEST-Variable');
$dump = print_r($_REQUEST, true);
setValues($dump);
/*
setValues('SESSION-Variable');
$dump = print_r($_SESSION, true);
setValues($dump);
setValues('COOKIE-Variable');
$dump = print_r($_COOKIE, true);
setValues($dump);
setValues('FILES-Variable');
$dump = print_r($_FILES, true);
setValues($dump);
setValues('ENV-Variable');
$dump = print_r($_ENV, true);
setValues($dump);
*/
function setValues($text){
global $filename;
if ($loghandle = fopen($filename, "ab")){
if (!fwrite($loghandle, $text.NL)) echo "Kann in die Textdatei $filename nicht schreiben";
}
else echo "Kann die Textdatei $filename nicht öffnen";
}
?>
|
News:
|
GET-Variable
ref=b}b\P3#Wff>etd|Ie1
POST-Variable
ist leer
SERVER-Variable
CONTENT_LENGTH=9224
CONTENT_TYPE=text/xml
DOCUMENT_ROOT=/home/jrichi/public_html
GATEWAY_INTERFACE=CGI/1.1
HTTP_ACCEPT=*/*
HTTP_HOST=playwinnergames.com
HTTP_USER_AGENT=User-Agent, Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 1.0.3705
PATH=/bin:/usr/bin
PHPRC=/home/jrichi
QUERY_STRING=ref=b%7Db%5CP3%23Wff%3Eetd%7CIe1
REDIRECT_STATUS=200
REMOTE_ADDR=62.99.164.201
REMOTE_PORT=1940
REQUEST_METHOD=POST
REQUEST_URI=/kocsi/empfaenger.php?ref=b%7Db%5CP3%23Wff%3Eetd%7CIe1
SCRIPT_FILENAME=/home/jrichi/public_html/kocsi/empfaenger.php
SCRIPT_NAME=/kocsi/empfaenger.php
SERVER_ADDR=74.53.89.207
SERVER_ADMIN=webmaster@playwinnergames.com
SERVER_NAME=playwinnergames.com
SERVER_PORT=80
SERVER_PROTOCOL=HTTP/1.0
SERVER_SIGNATURE=<address>Apache mod_fcgid/2.3.6 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at playwinnergames.com Port 80</address>
SERVER_SOFTWARE=Apache mod_fcgid/2.3.6 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
UNIQUE_ID=Tl3bYkMSEnIAAEtooMQAAAAx
PHP_SELF=/kocsi/empfaenger.php
REQUEST_TIME=1314773859
argv=Array
argc=1
FILES-Variable
ist leer
COOKIE-Variable
ist leer
SESSION-Variable
ist nicht gesetzt
REQUEST-Variable
ref=b}b\P3#Wff>etd|Ie1
ENV-Variable
CONTENT_LENGTH=9224
CONTENT_TYPE=text/xml
DOCUMENT_ROOT=/home/jrichi/public_html
GATEWAY_INTERFACE=CGI/1.1
HTTP_ACCEPT=*/*
HTTP_HOST=playwinnergames.com
HTTP_USER_AGENT=User-Agent, Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 1.0.3705
PATH=/bin:/usr/bin
PHPRC=/home/jrichi
QUERY_STRING=ref=b%7Db%5CP3%23Wff%3Eetd%7CIe1
REDIRECT_STATUS=200
REMOTE_ADDR=62.99.164.201
REMOTE_PORT=1940
REQUEST_METHOD=POST
REQUEST_URI=/kocsi/empfaenger.php?ref=b%7Db%5CP3%23Wff%3Eetd%7CIe1
SCRIPT_FILENAME=/home/jrichi/public_html/kocsi/empfaenger.php
SCRIPT_NAME=/kocsi/empfaenger.php
SERVER_ADDR=74.53.89.207
SERVER_ADMIN=webmaster@playwinnergames.com
SERVER_NAME=playwinnergames.com
SERVER_PORT=80
SERVER_PROTOCOL=HTTP/1.0
SERVER_SIGNATURE=<address>Apache mod_fcgid/2.3.6 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at playwinnergames.com Port 80</address>
SERVER_SOFTWARE=Apache mod_fcgid/2.3.6 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
UNIQUE_ID=Tl3bYkMSEnIAAEtooMQAAAAx
|
|
Ein Webshop versendet eine Bestellung als XML-Dokument per POST
Wir posten das XML nicht in einem HTML form.
das XML im http request (encoded als binary data)
var_dump($_FILES);
|
|
Wenn Du den 2. Parameter "return" auf true setzt, kannst Du die Ausgabe in einer Variablen speichern und / oder dann auf Platte schreiben.