• 쇼핑몰
  • 커뮤니티
  • 북마크

vb6.0/vba




[vb6.0/vba] [vb6.0/vba] 네이버 api를 이용한 http://me2.do/ 단축 URL 생성

하나를하더라도최선을
2020.07.01 09:46 316 0

본문



Sub me2do()    '// POST
    Dim URL As String, PostData As String, T As String, Cookie As String
    PostData = "url=http%3A%2F%2Fprogram1472.com%3Fcode%3D1024"
    With CreateObject("WinHttp.WinHttpRequest.5.1")
        .Open "POST", URL
        .SetRequestHeader "Host""openapi.naver.com"
        .SetRequestHeader "User-Agent""curl/7.49.1"
        .SetRequestHeader "Accept""*/*"
        .SetRequestHeader "Content-Type""application/x-www-form-urlencoded; charset=UTF-8"
        .SetRequestHeader "X-Naver-Client-Id""{애플리케이션 등록 시 발급받은 클라이언트 아이디 값}"
 
        .SetRequestHeader "X-Naver-Client-Secret""{애플리케이션 등록 시 발급받은 클라이언트 시크릿 값}"
        .SetRequestHeader "Content-Length", Len(PostData)
        .Send PostData
        .WaitForResponse: DoEvents
'         Cookie = SetCookie(Cookie, .GetAllResponseHeaders)
        T = .ResponseText
        'T = StrConv(.ResponseBody, vbUnicode)
    End With
    Debug.Print T
End Sub
 
 
Sub me2do()    '// GET
    Dim URL As String, T As String
    With CreateObject("WinHttp.WinHttpRequest.5.1")
        .Open "GET", URL
        .SetRequestHeader "accept""*/*"
        .SetRequestHeader "accept-language""ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7"
        .SetRequestHeader "content-type""plain/text"
        .SetRequestHeader "referer""https://developers.naver.com/apps/"
        .SetRequestHeader "sec-fetch-dest""empty"
        .SetRequestHeader "sec-fetch-mode""cors"
        .SetRequestHeader "sec-fetch-site""same-origin"
        .SetRequestHeader "user-agent""Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36"
        .SetRequestHeader "x-naver-client-id""{애플리케이션 등록 시 발급받은 클라이언트 아이디 값}"
        .SetRequestHeader "x-naver-client-secret""{애플리케이션 등록 시 발급받은 클라이언트 시크릿 값}"
        .SetRequestHeader "x-requested-with""XMLHttpRequest"
        .Send
        .WaitForResponse: DoEvents
'         Cookie = SetCookie(Cookie, .GetAllResponseHeaders)
        T = .ResponseText
        'T = StrConv(.ResponseBody, vbUnicode)
    End With
    Debug.Print T
End Sub


댓글목록 0

등록된 댓글이 없습니다.