출처:
http://shiflett.org/hacks/php/http_post
소켓으로 연결 해서 넘기는 방식 임다.
http_post
Discussion
This is a simple function that allows you to send an HTTP POST request to a Web server, whether local or
remote. It takes three arguments:
The host where the request is sent
The path of the resource that is receiving the request
The raw POST data to send
The function returns the raw HTTP response. Parse this as needed.
Listing
<?
function http_post($host, $path, $data)
{
$http_response = '';
$content_length = strlen($data);
$fp = fsockopen($host, 80);
fputs($fp, "POST $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-Type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-Length: $content_length\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data);
while (!feof($fp))
{
$http_response .= fgets($fp, 128);
}
fclose($fp);
return $http_response;
}
?>
Example
$http_response = http_post('example.org', '/path/to/script.php', 'first_name=chris&last_name=shiflett');
Comments
Comments are not available yet.
Trackback
Trackback Address :: http://mostech.zzlzzl.net/trackback/69


