예제 소스


$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;




Posted by 떼르미
,


자바스크립트를 허용해주세요!
Please Enable JavaScript![ Enable JavaScript ]