支払いが完了した後、サーバーが応答を$_POST
変数として送信する Web サービス サーバーと通信しています。試してみるとprint_r($_POST)
空のように見えますが、変数をテキスト ファイルに書き込むと、ファイルに値が表示されます。私の目標は、ユーザーの注文を完了するリンクを作成することです。$_POST 値はテキスト ファイルでのみ表示されるため、テキスト ファイルからリンクを読み取ってリダイレクトを実行しようとしていますが、別のページに到達すると $_GET 変数が空になります。以前、未加工の $_POST 変数を復元しようとしましたfile_get_contents("php://input")
が、成功しませんでした。これが私の実際のコードです:
<?php
ob_start();
// let's get the online response parameters...
$_VTransactionID = $_POST["VTransactionID"];
$_VAccountId = $_POST["VAccountId"];
$_VTotalAmount = $_POST["VTotalAmount"];
$_VPaymentMethod = $_POST["VPaymentMethod"];
$_VPaymentDescription = $_POST["VPaymentDescription"];
$_VAuthorizationNum = $_POST["VAuthorizationNum"];
$_VConfirmationNum = $_POST["VConfirmationNum"];
$_VMerchantTransId = $_POST["VMerchantTransId"];
////////Write LInk to file////////////////////////////////////
$fp = fopen("debug/OnlineResponseLog.log","w");
$link = "testvar.php?order_id=".$_VAccountId."&code=000&error=false&TxnGUID=".$_VConfirmationNum."\n\r";
if($fp){
fwrite($fp,$link);
fclose($fp);
}else{
printf("error while trying to write on online response Log");
}
////////////////////////////////////////////////////////////////////////////
/////REad LINK////////////////////////////////////////////////////
$fp = fopen("debug/OnlineResponseLog.log","r");
if($fp){
$cad = fread($fp,filesize("debug/OnlineResponseLog.log"));
fclose($fp);
}else{
printf("error while trying to read online response Log");
}
////////////////////////////////////////////////////
$url = $cad;
//To check if values where stored. Last char is used because last characters are supposed to be digits and not an equal sign.
$lastchar = substr($url, -1);
if($lastchar == "=")
$url ="testvar.php?order_id=&code=999&error=true&TxnGUID=";
header("Location: $url");
//////////////////
?>
どんな助けでも大歓迎です。$_POST
値が次の場所に表示されていれば、すべてのファイル書き込みを回避できます。print_r($_POST);