-1

CuRL なしで xml データを POST する必要があります。

多くのスニペットがありますが、何も機能していないようです。最新の試み:

function salesOrder($xml, $url)
{

  $context = stream_context_create(array(
    'http' => array(
      'method'  => 'POST',
      'header'  => "Content-type: application/xml\r\n",
      'content' => $xml,
      'timeout' => 5,
    ),
  ));
  $ret = file_get_contents($url, false, $context);

  return false !== $ret;
}

何も返しません。空白のページです。

http://wezfurlong.org/blog/2006/nov/http-post-from-php-without-curl/を試してみました

問題は、私がそれを本当に理解していないことであり、この問題をカバーする優れたチュートリアルが見つからないようです。誰かが私を正しい方向に向けることができますか?

4

1 に答える 1

1

これを使用してそれを達成できます

$xml = "<xml><name>hello</name></xml>" ;
$opts = array (
        'http' => array (
                'method' => "POST",
                'content' => $xml,
                'timeout' => 5,
                'header' => "Content-Type: text/xml; charset=utf-8" 
        ) 
);

$context = stream_context_create ( $opts );
$fp = fopen ( 'http://example.com/b.php', 'r', false, $context );
fpassthru ( $fp );
fclose ( $fp );

http://example.com/b.php

file_put_contents("php://output", file_get_contents("php://input"));
于 2012-05-10T15:34:40.897 に答える