Option Explicit
Sub program1472_com()
Dim URL As String, Cookie As String, PostData As String
Dim T As String
Dim accessToken As String, principal As String, credential As String
principal = "아이디"
credential = "비밀번호"
PostData = "{""principal"":""" & principal & """,""credential"":""" & credential & """,""macAddress"":""normal-browser""}"
With CreateObject("WinHttp.WinHttpRequest.5.1")
.Open "POST", URL
.SetRequestHeader "Accept", "application/json, text/javascript, */*; q=0.01"
.SetRequestHeader "Content-Type", "application/json"
.SetRequestHeader "X-Requested-With", "XMLHttpRequest"
.SetRequestHeader "Accept-Language", "ko-KR"
.SetRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
.SetRequestHeader "Host", "partner.alps.llogis.com"
.SetRequestHeader "Content-Length", Len(PostData)
.SetRequestHeader "Connection", "Keep-Alive"
.SetRequestHeader "Cache-Control", "no-cache"
If Len(Cookie) Then .SetRequestHeader "Cookie", Cookie
.Send PostData
.WaitForResponse: DoEvents
Debug.Print .getAllResponseHeaders
T = .ResponseText
End With
Debug.Print T
accessToken = Split(Split(T, """accessToken""")(1), """")(1)
With CreateObject("WinHttp.WinHttpRequest.5.1")
.Open "POST", URL
.SetRequestHeader "Accept", "application/json, text/javascript, */*; q=0.01"
.SetRequestHeader "Content-Type", "application/json"
.SetRequestHeader "Authorization", accessToken
.SetRequestHeader "X-Requested-With", "XMLHttpRequest"
.SetRequestHeader "Accept-Language", "ko-KR"
' .SetRequestHeader "Accept-Encoding", "gzip, deflate"
.SetRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
.SetRequestHeader "Host", "partner.alps.llogis.com"
.SetRequestHeader "Content-Length", "2"
.SetRequestHeader "Connection", "Keep-Alive"
.SetRequestHeader "Cache-Control", "no-cache"
If Len(Cookie) Then .SetRequestHeader "Cookie", Cookie
.Send
.WaitForResponse: DoEvents
Debug.Print .getAllResponseHeaders
T = .ResponseText
'T = StrConv(.ResponseBody, vbUnicode)
End With
Debug.Print T
End Sub