I'm using php to have several servers communicate between eachother. I
want to do the following:
Server A sends a request to server B. Server B stores some information
about this request, and sends back a response to A (so far it's regular
HTTP). Next, server B must send an HTTP request to server C.
How can I initiate an HTTP request to server C with PHP?
from http://www.php-center.de/faq/faq-scripts.html#scripts-3 :
function PostToHost($host, $path, $referer, $data_to_send) { $fp = fsockopen($host,80); printf("Open!\n"); fputs($fp, "POST $path HTTP/1.1\n"); fputs($fp, "Host: $host\n"); fputs($fp, "Referer: $referer\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\n"); fputs($fp, "Content-length: ".strlen($data_to_send)."\n"); fputs($fp, "Connection: close\n\n"); fputs($fp, "$data_to_send\n"); printf("Sent!\n"); while(!feof($fp)) { $res .= fgets($fp, 128); } printf("Done!\n"); fclose($fp);
return $res; }
$data = "pid=14&poll_vote_number=2";
printf("Go!\n"); $x = PostToHost( "www.linux.com", "/polls/index.phtml", "http://www.linux.com/polls/index.phtml?pid=14", $data );
Cheers, -sapporo.
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php