Centar za edukaciju-BiH



#1 06.03.2018 23:11
dex Van mreze
Super Moderator
Registrovan od:23.02.2012
Postovi:625


Predmet:Logovanje na sajt pomocu VBA
Da li je i kako moguce ulogovati se na sajt iz VB-a i proslediti podatke?

https://crf.trezor.gov.rs/

https://crf.trezor.gov.rs/...invoiceidf
↑  ↓

#2 07.03.2018 16:29
Gjoreski Van mreze
Administrator
Registrovan od:02.02.2009
Postovi:1,828


Predmet:Re: Logovanje na sajt pomocu VBA
Ova se WEB servisi ,jas do sega nemam koristeno nisto vakvo no eve sto najdov , mozebi ova ke pomogne
PreuzmiIzvorni kôd (Visual Basic):
  1. Public Function GetResponse(URI As String) As Boolean
  2.     Dim oHTTRequest As New WinHttp.WinHttpRequest
  3.     Dim oResult As String
  4.     On Error GoTo ErrRequest
  5.     oHTTRequest.Option(WinHttpRequestOption_EnableHttp1_1) = False
  6.     oHTTRequest.Open "GET", URI, False
  7.     oHTTRequest.setRequestHeader "X-Cons-ID", "XXXXXX (your cons-id)"
  8.     oHTTRequest.setRequestHeader "X-Timestamp", "XXXXX (timestamp)"
  9.     oHTTRequest.setRequestHeader "X-Signature", "XXXXX (your signature)"
  10.     oHTTRequest.send
  11.     If oHTTRequest.Status = 200 Then
  12.         GetResponse = True
  13.         oResult = oHTTRequest.responseText
  14.     Else
  15.         GetResponse = False
  16.         oResult = oHTTRequest.responseText
  17.     End If
  18.     Set oHTTRequest = Nothing
  19.     Exit Function
  20. ErrRequest:
  21.     Set oHTTRequest = Nothing
  22.     GetResponse = False
  23.     Err.Raise Err.Number, ", Err.Description"
  24. End Function
  25. Public Function PutResponse(URI As String) As Boolean
  26.     Dim oHTTRequest As MSXML2.XMLHTTP30
  27.     Dim oResult As String
  28.  
  29.     On Error GoTo ErrRequest
  30.      
  31.     Set oHTTRequest = New MSXML2.XMLHTTP30
  32.     oHTTRequest.Open "PUT", URI, False
  33.     oHTTRequest.setRequestHeader "X-Cons-ID", "XXXXXX (your cons-id)"
  34.     oHTTRequest.setRequestHeader "X-Timestamp", "XXXXX (timestamp)"
  35.     oHTTRequest.setRequestHeader "X-Signature", "XXXXX (your signature)"
  36.     oHTTRequest.setRequestHeader "Content-Type", "text/xml"
  37.     oHTTRequest.send "XML Data Put?"
  38.     oResult = oHTTRequest.responseText
  39.     If oHTTRequest.Status = 201 Or oHTTRequest.Status = 200 Then
  40.         PostResponse = True
  41.     Else
  42.         PostResponse = False
  43.     End If
  44.     Set oHTTRequest = Nothing
  45.     Exit Function
  46. ErrRequest:
  47.     PostResponse = False
  48.     Err.Raise Err.Number, ", Err.Description"
  49. End Function
  50. Public Function PostResponse(URI As String) As Boolean
  51.     Dim oHTTRequest As MSXML2.XMLHTTP30
  52.     Dim oResult As String
  53.  
  54.     On Error GoTo ErrRequest
  55.      
  56.     Set oHTTRequest = New MSXML2.XMLHTTP30
  57.     oHTTRequest.Open "POST", URI, False
  58.     oHTTRequest.setRequestHeader "X-Cons-ID", "XXXXXX (your cons-id)"
  59.     oHTTRequest.setRequestHeader "X-Timestamp", "XXXXX (timestamp)"
  60.     oHTTRequest.setRequestHeader "X-Signature", "XXXXX (your signature)"
  61.     oHTTRequest.setRequestHeader "Content-Type", "text/xml"
  62.     oHTTRequest.send "XML Data Post?"
  63.     oResult = oHTTRequest.responseText
  64.     If oHTTRequest.Status = 201 Or oHTTRequest.Status = 200 Then
  65.         PostResponse = True
  66.     Else
  67.         PostResponse = False
  68.     End If
  69.     Set oHTTRequest = Nothing
  70.     Exit Function
  71. ErrRequest:
  72.     PostResponse = False
  73.     Err.Raise Err.Number, ", Err.Description"
  74. End Function
  75. Public Function DeleteResponse(URI_Response As String) As Boolean
  76.     Dim oHTTRequest As MSXML2.XMLHTTP30
  77.     Dim oResult As String
  78.     On Error GoTo ErrRequest
  79.      
  80.     Set oHTTRequest = New MSXML2.XMLHTTP30
  81.     oHTTRequest.Open "DELETE", URI, False
  82.     oHTTRequest.setRequestHeader "X-Cons-ID", fields.xConsID
  83.     oHTTRequest.setRequestHeader "X-Timestamp", fields.xTimeStamp
  84.     oHTTRequest.setRequestHeader "X-Signature", fields.xSignature
  85.     oHTTRequest.setRequestHeader "Content-Type", "text/xml"
  86.     oHTTRequest.send "XML Data Delete?"
  87.     oResult = oHTTRequest.responseText
  88.     If oHTTRequest.Status = 201 Or oHTTRequest.Status = 200 Then
  89.         DeleteResponse = True
  90.     Else
  91.         DeleteResponse = False
  92.     End If
  93.     Set oHTTRequest = Nothing
  94.     Exit Function
  95. ErrRequest:
  96.     DeleteResponse = False
  97.     Err.Raise Err.Number, ", Err.Description"
  98. End Function
↑  ↓

Stranice (1):1


Sva vremena su GMT +01:00. Trenutno vrijeme: 10: 11 am.