0
我正在收集表單上的數據並通過POST將數據發送到收集和分發表單主管的外部服務器。外部服務器將XML響應發送回我的服務器。如何在收到POST響應時運行php?
我已經爲響應php腳本設置了重定向URL。我希望腳本解析XML響應並激發其中一個字段中提供的像素。我也希望系統在每次收到回覆時給我發電子郵件。
我的問題
該系統的工作,如果我手動輸入XML響應,並在我的 瀏覽器加載它。當在 背景中發送迴應時,它不執行腳本。
使用tshark
我一直在監視流量,並且每次提交表單時,php腳本都會被命中,但沒有任何執行。
我當前的代碼
<?php
//Example Post from Lead Server
$server_output2=
'<?xml version="1.0" encoding="UTF-8"?>
<response>
<status>Unmatched</status>
<lead_id>69</lead_id>
<tracking_pixel>https://demo.leadportal.com/genericPostlead.php?TYPE=79&amp;SRC=pixeltestingforcege</tracking_pixel>
</response>';
//Live Server Response
$server_output = file_get_contents('php://input');
if (!empty($server_output)) {
$xml = simplexml_load_string($server_output) or die("Error: Cannot create object");
}
//XML Parse of Lead Server Response
$status=$xml->status;
$lead_id=$xml->lead_id;
$pixel=$xml->tracking_pixel;
?>
<!-- This is the HTML Section to test and Display the Status and LeadID -->
The status is <span style="font-weight:bold;color:red;"><?php if(!empty($status)) echo $status; else{echo "n/a";} ?></span> and the lead id is <span style="font-weight:bold;color:red;"><?php if(!empty($lead_id)) echo $lead_id; else{echo "n/a";} ?></span>
<br>
<!-- This is the Pixel Fire from the Response-->
<h3>Pixel Here!
<iframe src="<?php echo $pixel; ?>" height="1" width="1" frameborder="1" style="border:medium double red"></iframe></h3>
<?php
$to = "[email protected]";
$subject = "XML Response";
$message ="
Hello
$xml
$server_output
$server_output2
";
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to,$subject,$message,$headers);
?>
一個重定向總是來自瀏覽器的'GET'請求時,它不能從外部服務器發送'POST'數據。 – Barmar