简体   繁体   中英

POST data and maintain connection to receive response

Is it possible to POST dat via PHP, and maintain the connection in order to recieve a response? My thinking would be that in order to have a two way conversation going, I would POST data by cURL and then provide the second party with another URL in order to talk back to me.

However I am being told:

When you do a POST via HTTPS, all you need to do is to wait for the response to be returned to you via the same connection, our server will keep returning a sequence of HTML comments while the order is being processed.

How is this possible with PHP and cURL? Or is there some other connection functions that I am unaware of?

Please help as I am at a loss with this one :S

cUrl is a correct set of functions to do it.

Please read about CURLOPT_RETURNTRANSFER at http://www.php.net/manual/en/function.curl-setopt.php .

Generally speaking, you need something likes:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, '...');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_VERBOSE, false);

curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, ...);

$response = curl_exec($ch);
curl_close($ch)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM