BACKRUSH  À¯´Ð½º¸í·É  ´ÙÀ½  ÀÚ·á½Ç  Ascii Table   ¿ø°ÝÁ¢¼Ó  ´Þ·Â,½Ã°£   ÇÁ·Î¼¼½º   ½©
ÁöÇÏö³ë¼±   RFC¹®¼­   SUN FAQ   SUN FAQ1   C¸Þ´º¾ó   PHP¸Þ´º¾ó   ³Ê±¸¸®   ¾Æ½ºÅ°¿ùµå ¾ÆÀÌÇǼ­Ä¡

±Û¾´ÀÌ: PHP GET/POST Àü¼Û Á¶È¸¼ö: 13028



[ get ¹æ½Ä ]



<?

$server = "itn.pe.kr";

$port = 80;

$method = "get";


$path = "/method_test.php";

$header = array();

$variable = array();

$config = array("version" => "1.0","name" => "Get files through http protocol","debugname" => "http_method.php");

$header["Accept"] = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";

$header["Referer"] = "/";

$header["Accept-Language"] = "ko";

$header["Content-Type"] = "application/x-www-form-urlencoded";

$header["User-Agent"] = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)";

$header["Host"] = $server;

$header["Connection"] = "Keep-Alive";

$header["Cache-Control"] = "no-cache";


$variable["test_data"] = "Translation complete!";


$sock = @fsockopen($server, $port);

if (!$sock) $Error("Cannot open socket [$server:$port]");


if ($variable) {

$aid_url = "?";

foreach ($variable as $key => $value) {

$key = urlencode($key);

$value = urlencode($value);

if ($aid_url == "?") $aid_url .= $key."=".$value;

else $aid_url .= "&".$key."=".$value;

}

}


$cmd = "GET ".$path.$aid_url." HTTP/1.1";

if (!$header) $Error("No Any HTTP Headers.");


foreach ($header as $key => $value) {

$cmd .= "\r\n".$key.": ".$value;

}


$cmd .= "\r\n\r\n";

fputs($sock, $cmd);

$str_get = "";


while (!feof($sock)) {

$str_get .= fgets($sock, 1024);

}


echo("$str_get");

?>


[ POST ¹æ½Ä ]


<?

$server = "itn.pe.kr";

$port = 80;

$method = "post";

$path = "/method_test.php";

$header = array();

$variable = array();

$config = array("version" => "1.0","name" => "Get files through http protocol","debugname" => "http_method.php");

$header["Accept"] = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";

$header["Referer"] = "/";

$header["Accept-Language"] = "ko";

$header["Content-Type"] = "application/x-www-form-urlencoded";

$header["User-Agent"] = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)";

$header["Host"] = $server;

$header["Connection"] = "Keep-Alive";

$header["Cache-Control"] = "no-cache";


$variable["test_data"] = "Translation complete!";


$sock = @fsockopen($server, $port);

if (!$sock) $Error("Cannot open socket [$server:$port]");


if ($variable) {

$aid_query = "";


foreach ($variable as $key => $value) {

$key = urlencode($key);

$value = urlencode($value);

if (!$aid_query) $aid_query .= $key."=".$value;

else $aid_query .= "&".$key."=".$value;

}

}


$cmd = "POST ".$path." HTTP/1.1";

if (!$header) $Error("No Any HTTP Headers.");


$strlen = strlen($aid_query);

$header["Content-Length"] = $strlen;


foreach ($header as $key => $value) {

$cmd .= "\r\n".$key.": ".$value;

}


$cmd .= "\r\n\r\n";

$cmd .= $aid_query;


fputs($sock,$cmd);

$str_get = "";


while (!feof($sock)) {

$str_get .= fgets($sock, 1024);

}


echo("$str_get")

?>




°ü·Ã±Û : ¾øÀ½ ±Û¾´½Ã°£ : 2008/10/05 23:36 from 119.196.113.10

  [ÀÀ´ä]phpÀ¸·Î ÀÛ¾÷°ü¸®ÀÚ¸¦ ¸¸µé·Á°í Çϴµ¥¿ä ¸ñ·Ïº¸±â »õ±Û ¾²±â Áö¿ì±â ÀÀ´ä±Û ¾²±â ±Û ¼öÁ¤ http Á¢¼Ó  CLASS[php]  
BACKRUSH  À¯´Ð½º¸í·É  ´ÙÀ½  ÀÚ·á½Ç  Ascii Table   ¿ø°ÝÁ¢¼Ó  ´Þ·Â,½Ã°£   ÇÁ·Î¼¼½º   ½©
ÁöÇÏö³ë¼±   RFC¹®¼­   SUN FAQ   SUN FAQ1   C¸Þ´º¾ó   PHP¸Þ´º¾ó   ³Ê±¸¸®   ¾Æ½ºÅ°¿ùµå ¾ÆÀÌÇǼ­Ä¡