<% '--------------------한글깨짐 방지-------------------- %>
<%@Language="VBScript" CODEPAGE="65001" %>
<%
Response.CharSet="utf-8"
Session.codepage="65001"
Response.codepage="65001"
Response.ContentType="text/html;charset=utf-8"
%>
<% '----------------------------------------------------- %>
<%
'--------------------API 연결----------------------------
Dim http
Set http = Server.CreateObject("Microsoft.XMLHTTP")
http.Open "유형(GET,POST..)", "주소", 비동기/동기(TRUE, FALSE)
'header에 실을 값
http.SetRequestHeader "Content-Type", "application/json"
http.SetRequestHeader "key", "value"
'API에 보낼 데이터(JSON 형식)
http.Send "{""KEY1"":""DATA1"", ""KEY2"":""DATA2"", ""KEY3"":""DATA3""}"
'API 연결 성공 시(http.Status = 200)
ASPPostJSON = CStr(http.ResponseText)
'응답 내역
Response.write(ASPPostJSON)
Set http = Nothing
'--------------------------------------------------------
%>
이렇게 하면 classic asp에서 Restful api 연결 가능하다.
만약 javascript - ajax로 asp 파일 연결하여 데이터를 가져온다면
ajax에서 dataType:"json" 설정하면 json형식으로 값 가져올 수 있다.
참고:https://stackoverflow.com/questions/8144368/can-a-classic-asp-page-using-xmlhttp-make-a-json-request
'CODING > ASP' 카테고리의 다른 글
[ASP.NET] .aspx에서 .aspx.cs 함수 호출하는 법 (0) | 2022.12.27 |
---|