2016-04-11 13 views
0

私たちは現在、私たちのサーバー上のURLにxmlポストバックのためにUltracartを使用しています。私がしようとしているのはxmlを受け取り、右折して別のページに投稿することです。 (私たちは、トラブル我々が取り組んでいるプロジェクトのために複数のソースにポストバックを送信したた。)ここで私がプレーしてきたものです:私はここで重要な何かが欠けている知っているrepost xml別のURLにポストバック

$xml = file_get_contents('php://input'); 
$url = 'https://destinationlink'; 


$post_data = array(
    "xml" => $xml, 
); 

$stream_options = array(
    'http' => array(
     'method' => 'POST', 
     'header' => "Content-type: application/x-www-form-urlencoded\r\n", 
     'content' => http_build_query($post_data), 
    ), 
); 
$context = stream_context_create($stream_options); 
$response = file_get_contents($url, null, $context); 

... I私はそれをあまりにも長く見てきたと思うし、私は問題を見ることができない...おそらく何かばかげた単純な。

答えて

0

ここで答えはCURLでした。

//URL where to send the data via POST 
$URL1 = 'http://destinationlink'; 

//the actual data 
$xml_data1 = file_get_contents('php://input'); 


    $ch1 = curl_init($URL1); 
    curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, 0); 
    curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, 0); 
    curl_setopt($ch1, CURLOPT_POST, 1); 
    curl_setopt($ch1, CURLOPT_HTTPHEADER, array('Content-Type: text/xml')); 
    curl_setopt($ch1, CURLOPT_POSTFIELDS, "$xml_data1"); 
    curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1); 
    $output1 = curl_exec($ch1); 
    curl_close($ch1); 

これは魅力的です。

XMLポストバック(php:// input)を受け取って、このURLコードを使用して目的のURLに基​​づいて異なるブロックを作成し、必要なすべての個別の接続に情報を送信することができます。

関連する問題