BIG

요즘은 각종 API 가 많이 제공된다.

그리고 대부분의 API 는 restful 형식이라는 포맷을 가진다.

그리고 대부분의 API 의 호출프로토콜은 HTTP 를 사용한다.

따라서 VBA 에서도 HTTP 호출을 이용하면

여러곳에 공개되어 있는 많은 API 를 연동하여 필요한 자료들을 수집하여 활용할 수 있다.

 

Function RequestHttp(ByVal RequestUrl As String) As String

    Dim ResponseText

    Set winHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
        winHttpReq.Open "GET", RequestUrl, False
        winHttpReq.Send
        winHttpReq.WaitForResponse
        
        ResponseText = winHttpReq.ResponseText
        
    Set winHttpReq = Nothing

        
    RequestHttp = ResponseText

End Function


    TargetUrl = ""
    RequestUrl = ""
    ShortUrlParms = SourceUrlParms & "-" & loopCnt2
    TargetUrl = SourceUrl & "?parms=" & ShortUrlParms
    RequestUrl = ApiUrl & TargetUrl
    ResponseText = RequestHttp(ApiUrl_urlCount)

    Msgbox( ResponseText )
LIST