예제 소스
$host = "target.domain1.com";
$uri = "/Logon/XMLServerAPI.asp";
$request = "<?xml version=\"1.0\" encoding=\"euc-kr\"?>\r\n";
$request .= "<request>\r\n";
$request .= " <node>".$data."</node>\r\n";
$request .= "</request>\r\n";
$result = xu_query_http_post($request, $host, $uri, 80, 0, "", "", false);
/* generic function to call an http server with post method */
function xu_query_http_post($request, $host, $uri, $port, $debug, $user, $pass, $secure=false) {
$response_buf = "";
if ($host && $uri && $port) {
$content_len = strlen($request);
$fsockopen = $secure ? "fsockopen_ssl" : "fsockopen";
$query_fd = $fsockopen($host, $port, $errno, $errstr, 10);
if ($query_fd) {
$auth = "";
if ($user) {
$auth = "Authorization: Basic " .
base64_encode($user . ":" . $pass) . "\r\n";
}
$http_request =
"POST $uri HTTP/1.0\r\n" .
"User-Agent: xmlrpc-epi-php/0.2 (PHP)\r\n" .
"Host: $host:$port\r\n" .
$auth .
"Content-Type: text/xml\r\n" .
"Content-Length: $content_len\r\n" .
"\r\n" .
$request;
fputs($query_fd, $http_request, strlen($http_request));
while (!feof($query_fd)) {
$line = fgets($query_fd, 4096);
if (!$header_parsed) {
if ($line === "\r\n" || $line === "\n") {
$header_parsed = 1;
}
}
else {
$response_buf .= $line;
}
}
fclose($query_fd);
}
}
return $response_buf;
}
'Tech: > Linux·PHP' 카테고리의 다른 글
Linux에 PHP + Apache + MySQL 설치하기 (0) | 2008.06.26 |
---|---|
기타 유용한 정보들 (0) | 2008.06.26 |
SAX(Simple Application for XML) 구현하기 (0) | 2008.06.26 |
Windows 2000에 PHP 모듈 설치법 (0) | 2008.06.26 |
UNIX - Linux 명령어 모음 (0) | 2008.06.26 |