Java/C#/PHP 코드를 사용하여 기본 인증을 사용하는 XML 데이터 가져오기

  • 릴리스 버전: Zurich
  • 업데이트 날짜 2025년 07월 31일
  • 소요 시간: 1분
  • 로컬 데이터 저장소를 사용할 수 없는 경우 데이터를 가져오는 또 다른 방법은 CSV/XML 프로세서를 직접 호출한 다음 결과를 구문 분석하는 것입니다.

    직접 SOAP 호출과 비슷한 방식으로 결과 데이터를 사용합니다. PHP에서 이것의 예 :

    <?php
    //This example is in PHP 
     
    	$user = "itil";
    	$pass = "itil";
            $userPass = $user.':'.$pass;
     
     
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, 'https://<instance name>.service-now.com/incident_list.do?CSV');
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
            curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
            curl_setopt($ch, CURLOPT_USERPWD, $userPass);
     
            $data = curl_exec($ch);
            $info = curl_getinfo($ch);
     
            if ($output === false) {
              $output = "No cURL data returned for $addr [". $info['http_code']. "]";
              if (curl_error($ch))
                  $output .= "\n". curl_error($ch);
              print $output;
            }
            else{
              echo $data;
            }
            curl_close($ch);
    ?>