我要发送cURL帖子必须做什么才能“回应”?

I have a very simply script on a site. That script is sending an HTTP POST to another site that I have control of. I understand how to use cURL to send the POST, but what does the script I'm sending it to have to have on it to respond?

For example, here is the code that is sending the POST (I would like it if this script echoed back the response from site B, but I don't even know how to get site B to respond to the post):

<?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;

?>

Then site b, at the URL the POST above is being sent to, the following code is there:

<?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"; }


?>

What needs to go on the script at site B to respond with the text that appears on screen based on the "if logic" in the script?

Response of site B is any output sent. You have an error in your code:

$echo "This is what you see..."

should be

echo "This is what you see..."

I guess that's why you don't see any reply.

In order to see if the request was successful you can (during testing) echo some string at start or end of the script as site B. Example:

<?php
echo 'Hi, I\'m site B!<br/>';
$postvar1 = $_POST['postvar1'];

You just do normal HTML output (or JSON, or whatever), exactly as you would be responding to a normal POST done by a web browser.