サイトに非常に単純なスクリプトがあります。そのスクリプトは、私が管理している別のサイトに HTTP POST を送信しています。cURL を使用して POST を送信する方法は理解していますが、送信するスクリプトが応答するために必要なものは何ですか?
たとえば、POST を送信しているコードは次のとおりです (このスクリプトがサイト B からの応答をエコー バックしたいのですが、サイト B が投稿に応答するようにする方法さえ知りません)。
<?php
//
// A very simple PHP example that sends a HTTP POST to a remote site
//
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://www.mysite.com/tester.phtml");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"postvar1=value1&postvar2=value2&postvar3=value3");
// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
echo $server_output;
?>
次に、上記の POST が送信されている URL のサイト b に、次のコードがあります。
<?php
$postvar1 = $_POST['postvar1'];
if ($postvar1="apples and oranges") {
$echo "This is what you see if postvar1 has been posted and is equal to apples and oranges"; } else {echo "this is what you see if postvar1 has not been posted or is not equal to apples and oranges"; }
?>
スクリプトの「if ロジック」に基づいて画面に表示されるテキストで応答するには、サイト B のスクリプトで何を実行する必要がありますか?