OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Accessing HTTPS websites through OO Basic

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets
View previous topic :: View next topic  
Author Message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Tue Sep 15, 2009 2:17 pm    Post subject: Accessing HTTPS websites through OO Basic Reply with quote

Hi,

this http://www.oooforum.org/forum/viewtopic.phtml?t=88592 thread showed me to the subject ...

Below is a solution, tested on OO 3.1 / XP SP3. There are some peculiarities:
- I believe, that even if an https site shows up in IE, you have to manually install the certificte (right click on open page, properties/certificates). Can somebody confirm this ?
- There seems to be some caching of the acceptance of certain certicicates (in my code by selecting the second continuation request). Sometimes, it is necessary to completely leave OO and restart to get the same results

Good luck,

ms777

Code:
Global ms777_InteractionHandler as Any

Sub Main

  aURL = "https://dpinfo.dpma.de/index_e.html"

  Dim keys(1) as String
  keys( 0 ) = "Local"
  keys( 1 ) = "Office"
 
  oUCB = getProcessServiceManager().createInstanceWithArguments("com.sun.star.ucb.UniversalContentBroker", keys )

  xId = oUCB.createContentIdentifier(aURL)
  xContent = oUCB.queryContent(xId)

'create some empty command environment 
  oCommandEnvironment = createUnoListener("XCE_", "com.sun.star.ucb.XCommandEnvironment")
  ms777_InteractionHandler = createUnoListener("XIH_", "com.sun.star.task.XInteractionHandler")

'find out, if it is really a document
  Dim aProps(0) as new com.sun.star.beans.Property
  aProps(0).Name = "IsDocument"
  aProps(0).Handle = -1

  xValues = executeCommand(xContent, "getPropertyValues", aProps, oCommandEnvironment)
  iCol = xValues.findColumn("IsDocument")
  bResult = xValues.getBoolean(iCol)
  if bResult<>true then
    msgbox "no document"
    exit sub
  endif

'open an outputstream
  sFileOut = "C:\dummy.txt"
  oSFA = createUNOService ("com.sun.star.ucb.SimpleFileAccess")
  if oSFA.exists(sFileOut) then oSFA.kill(sFileOut)
  oFileOut= oSFA.openFileWrite(sFileOut)

 
'now try to open
  Dim oOpenCommand as new com.sun.star.ucb.OpenCommandArgument2
  oOpenCommand.Mode = com.sun.star.ucb.OpenMode.DOCUMENT
  oOpenCommand.Sink = oFileOut

  executeCommand(xContent, "open", oOpenCommand, oCommandEnvironment)
 
  oFileOut.flush
  oFileOut.closeOutput
End Sub

function executeCommand(xContent as com.sun.star.ucb.XContent, aCommandName as String, aArgument as Any, oCommandEnvironment as Any) as Any
  Dim aCommand as new com.sun.star.ucb.Command
  aCommand.Name = aCommandName
  aCommand.Handle = -1
  aCommand.Argument = aArgument
 
  executeCommand = xContent.execute(aCommand, 0, oCommandEnvironment)
end function


function XCE_getInteractionHandler() as com.sun.star.task.XInteractionHandler
  XCE_getInteractionHandler =  ms777_InteractionHandler
end function

function XCE_getProgressHandler() as com.sun.star.ucb.XProgressHandler
end function

sub XIH_handle(xRequest as com.sun.star.task.XInteractionRequest)
  oRequest = xRequest.Request

  strResponse = "Response from InteractionHandler:" & Chr(13)
  strMessage = ""
  strDiagnostic = ""
  Dim oCertificate as Any
'  msgbox IsEmpty(oCertificate)
 
  on Error resume next
  strResponse = strResponse & "Message: " & oRequest.Message & Chr(13)
  strResponse = strResponse & "Diagnostic: " & oRequest.Diagnostic & Chr(13)
  oCertificate = oRequest.Certificate
  on Error goto 0
  if IsEmpty(oCertificate) then
    strResponse = strResponse & "Certificate: none" & Chr(13)
  else
    strResponse = strResponse & "Certificate IssuerName:" & oCertificate.IssuerName & Chr(13)
  endif


  aContinuation = xRequest.Continuations
  lUBound = UBound(aContinuation)

  strResponse = strResponse & Chr(13) & "# of continuations:" & (lUBound+1) & ", will select last ..."
  msgbox strResponse

  if lUBound=1 then
    aContinuation(1).select
  endif
 
  if lUBound=0 then
    aContinuation(0).select
  endif

end sub
Back to top
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Wed Sep 16, 2009 2:37 pm    Post subject: Reply with quote

... and a simplified version, using the predefined InteractionHandler. I did not find it before ...
Code:
Sub Main
  aURL = "https://dpinfo.dpma.de/index_e.html"

  oUCB = createUnoService("com.sun.star.ucb.UniversalContentBroker")
  oUCB.Initialize(Array("Local", "Office"))

  xId = oUCB.createContentIdentifier(aURL)
  xContent = oUCB.queryContent(xId)

'create some empty command environment 
  oCommandEnvironment = createUnoListener("XCE1_", "com.sun.star.ucb.XCommandEnvironment")

'find out, if it is really a document
  Dim aProps(0) as new com.sun.star.beans.Property
  aProps(0).Name = "IsDocument"
  aProps(0).Handle = -1

  xValues = executeCommand(xContent, "getPropertyValues", aProps, oCommandEnvironment)
  iCol = xValues.findColumn("IsDocument")
  bResult = xValues.getBoolean(iCol)
  if bResult<>true then
    msgbox "no document"
    exit sub
  endif

'open an outputstream
  sFileOut = "C:\dummy.txt"
  oSFA = createUNOService ("com.sun.star.ucb.SimpleFileAccess")
  if oSFA.exists(sFileOut) then oSFA.kill(sFileOut)
  oFileOut= oSFA.openFileWrite(sFileOut)

 
'now try to open
  Dim oOpenCommand as new com.sun.star.ucb.OpenCommandArgument2
  oOpenCommand.Mode = com.sun.star.ucb.OpenMode.DOCUMENT
  oOpenCommand.Sink = oFileOut

  executeCommand(xContent, "open", oOpenCommand, oCommandEnvironment)
 
  oFileOut.flush
  oFileOut.closeOutput
End Sub

function executeCommand(xContent as com.sun.star.ucb.XContent, aCommandName as String, aArgument as Any, oCommandEnvironment as Any) as Any
  Dim aCommand as new com.sun.star.ucb.Command
  aCommand.Name = aCommandName
  aCommand.Handle = -1
  aCommand.Argument = aArgument
 
  executeCommand = xContent.execute(aCommand, 0, oCommandEnvironment)
end function


function XCE1_getInteractionHandler() as com.sun.star.task.XInteractionHandler
  XCE1_getInteractionHandler =   createUnoService("com.sun.star.task.InteractionHandler")
end function

function XCE1_getProgressHandler() as com.sun.star.ucb.XProgressHandler
end function
Back to top
View user's profile Send private message
adamzad
General User
General User


Joined: 08 Mar 2011
Posts: 16
Location: Buena Park, CA, USA

PostPosted: Mon May 02, 2011 8:29 pm    Post subject: Reply with quote

This code does exactly what I need to do... except... instead of dumping the returned page from the web server into a file on the hard drive (oOpenCommand.Sink = oFileOut), I need to dump the HTML into a string variable. To that end, I've been trying to merge this code with the LoadComponentFromURL code specified here:

http://www.oooforum.org/forum/viewtopic.phtml?p=26353

I'm encountering some difficulty figuring out how to specify a variable as the data sink, though. Does anyone know of a quick, easy way to shift the output from a file to a variable?

Thanks in advance!

Fair day and be well,
Adam-Zad, The Bear That Looks Like A Man
Back to top
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Tue May 03, 2011 9:51 am    Post subject: Reply with quote

adamzad wrote:
This code does exactly what I need to do...


nice to hear Smile

for avoiding the writing to file, I recommend using the technique from http://www.oooforum.org/forum/viewtopic.phtml?p=302514#302514 :
Code:
'create a temporary storage
oStorageFac = createUnoService("com.sun.star.embed.StorageFactory")
oStorage    = oStorageFac.createInstance
oStream     = oStorage.openStreamElement("ms777", com.sun.star.embed.ElementModes.READWRITE)

'now write the HTML String to the stream
oTextOutputStream = createUNOService ("com.sun.star.io.TextOutputStream")
oTextOutputStream.setOutputStream(oStream)
oTextOutputStream.writeString(sHTML)
oTextOutputStream.flush
oTextOutputStream.closeOutput


In your case, you will have to pass oStream to oOpenCommand.Sink, create a TextInputStream, and then read the string from it

Good luck,

ms777
Back to top
View user's profile Send private message
adamzad
General User
General User


Joined: 08 Mar 2011
Posts: 16
Location: Buena Park, CA, USA

PostPosted: Tue May 03, 2011 6:03 pm    Post subject: Reply with quote

OK, to see if I understand the internal workings of this script... (note that I've been using Option Explicit to avoid having my typos create unknown variables - Thanks a lot, Dad, for passing the OCD on to me! Laughing )
Code:
'create a temporary storage
  Dim oStorageFac as Object
  Dim oStorage as Object
  Dim oStream as Object
 
  oStorageFac = createUnoService("com.sun.star.embed.StorageFactory")
  oStorage    = oStorageFac.createInstance
  oStream     = oStorage.openStreamElement("WebReply", com.sun.star.embed.ElementModes.READWRITE)

This code sets up a Storage Factory, then hooks the oStream object variable to the Stream Element Storage Factory. I'm pretty sure I understand that correctly (please correct me if I'm wrong). Does the Stream Name (WebReply, in this instance) have any significance?


Code:
'now try to open
  Dim oOpenCommand as new com.sun.star.ucb.OpenCommandArgument2
 
  oOpenCommand.Mode = com.sun.star.ucb.OpenMode.DOCUMENT
  oOpenCommand.Sink = oStream                            'Changed from "oFileOut" in original code snippet.

This sets the Command Sink (returned page from Web Server) to dump into Stream Element Storage Factory (hooked to oStream in the previous code). Do I have to change the oOpenCommand.Mode to something other than "document"? I couldn't find anything else that seemed to make sense in the Developer's Guide and API Documentation. Do I even need to specify an oOpenCommand.Mode at all, given that I'm hooking it to a Stream Element?


Code:
  Dim oInputText as Object
  Dim sFileText as String
 
  oInputText = createUNOService ("com.sun.star.io.TextInputStream")
  sFileText = oInputText.setInputStream(oStream).ReadString( , TRUE)
'sFileText = oInputText.readString( , TRUE)
  oInputText.Flush
  oInputText.CloseInput

This would make oInputText the Text Input Stream, pipe oStream into it, read the entire stream, and dump it into the string variable sFileText. Do I have it right so far? Also, do I have to split up the setInputStream and ReadString lines, or can I get away with hooking them all together on the same line?

And, of course, clean up with the Flush and CloseInput... come to think of it, I'd have to clean up oStream and oOpenCommand, too, wouldn't I? I don't need to worry about delimiters, as I'm taking the HTML file from the Web Server and dumping it, in its entirety, into the string variable. Once I have it in the string variable, I can use InStr() to search for the keywords I need to find.

Any corrections or improvements to my code would be greatly appreciated. With few exceptions, this forum has greatly increased my knowledge and understanding of OpenOffice, and I am deeply grateful! Very Happy

Fair day and be well,
Adam-Zad, The Bear That Looks Like A Man
Back to top
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Wed May 04, 2011 2:05 pm    Post subject: Reply with quote

adamzad wrote:
... Does the Stream Name (WebReply, in this instance) have any significance?
no


adamzad wrote:
...Do I have to change the oOpenCommand.Mode to something other than "document"? .... Do I even need to specify an oOpenCommand.Mode at all, given that I'm hooking it to a Stream Element?
I would guess for "no" and "yes" as the answers. Simply try it ...

adamzad wrote:

Code:
  Dim oInputText as Object
  Dim sFileText as String
 
  oInputText = createUNOService ("com.sun.star.io.TextInputStream")
  sFileText = oInputText.setInputStream(oStream).ReadString( , TRUE)
'sFileText = oInputText.readString( , TRUE)
  oInputText.Flush
  oInputText.CloseInput

This would make oInputText the Text Input Stream, pipe oStream into it, read the entire stream, and dump it into the string variable sFileText. Do I have it right so far? Also, do I have to split up the setInputStream and ReadString lines, or can I get away with hooking them all together on the same line?
I believe you have to use something like
Code:
 
  oInputText = createUNOService ("com.sun.star.io.TextInputStream")
  call oInputText.setInputStream(oStream)
  sFileText = oInputText.readString( , TRUE)
  oInputText.Flush
  oInputText.CloseInput


Good luck,

ms777
Back to top
View user's profile Send private message
adamzad
General User
General User


Joined: 08 Mar 2011
Posts: 16
Location: Buena Park, CA, USA

PostPosted: Wed May 04, 2011 6:26 pm    Post subject: Reply with quote

Woo Hoo!! After MUCH trial and error, I got it to work! Very Happy

Here's the code:

Code:
'Now, move returned page into a string variable.
  Dim oInputText as Object
  Dim sFileText as String
  Dim DummyArray(0) : DummyArray(0) = ""
 
  oInputText = createUNOService ("com.sun.star.io.TextInputStream")
  oInputText.setInputStream(oStream)
  oInputText.InputStream.Seek(0)
  sFileText = oInputText.readString(DummyArray(), FALSE)
  oInputText.InputStream.Flush
  oInputText.CloseInput


Yes, you have to set oInputText.InputStream.Seek(0) - though I think "1" would have worked just as well - because the initial position of oInputText is the EOF, so you always wind up with an empty string. You also MUST have the array defined and filled, even if, as in my case, it was filled with an empty string. If you feed ReadString an uninitialized array, it gives you back an empty string. For my purposes, removal of the delimiter made no difference, as I was reading to EOF anyway. I'm not positive I had to Flush oInputText.InputStream, but I figured it was probably a good idea to clean up after myself, and it made no difference in the textual output.

Thank you, all (especially ms777, who provided most of the code and the best advice) for your help! Very Happy

Fair day and be well,
Adam-Zad, The Bear That Looks Like A Man
Back to top
View user's profile Send private message
Fernand
OOo Enthusiast
OOo Enthusiast


Joined: 22 Jun 2004
Posts: 142

PostPosted: Tue May 24, 2011 11:21 pm    Post subject: Reply with quote

Hallo,
I trie to connect to Googleapis using OO and https ?

Code:
oConnector = createUnoService("com.sun.star.connection.Connector")
oConnection = oConnector.connect("socket,host=www.googleapis.com,port=80")
oConnection.write( StringToByteArray( "GET https://www.googleapis.com/tasks/v1/lists/MDk5Nzc1MDY0NzQyMTk4NjEyMzM6MDow/tasks/MDk5Nzc1MDY0NzQyMTk4NjEyMzM6MDo4?pp=1&key={YOUR_API_KEY}" + cCR + cLF & _
"Authorization: OAuth 1/kGy97RzqEi3JpSHlsBcaa0zL-hCNNzbbFRpHClhpnm4" + cCR + cLF
oConnection.flush()
aByteArray = Array()
nBytesRead = oConnection.read(aByteArray, 5000)
oPipe = createUNOService ("com.sun.star.io.Pipe") ' heeft zowel een In als OUtput stream
oTextInp = createUNOService ("com.sun.star.io.TextInputStream") 'kan lezen
oTextOut = createUNOService ("com.sun.star.io.TextOutputStream")' kan schrijven
oTextInp.setInputStream(opipe) 'maakt dat pipe kan lezen
otextOut.setOutputStream(opipe) 'maakt dat pipe kan schrijven
otextout.setencoding("ISO-8859-1")

otextOut.writestring(ByteArrayToString(aByteArray)) 'schrijft de string naar Pipe

s = oTextinp.readstring(Array("}"), true)
msgbox(s)


but the respons (s) is Google saying that i must use SSL
Then a had a look at "Ms777 solution" using UCB, But "GET" do not return a "page"
Thanks for any hint
Back to top
View user's profile Send private message Send e-mail
adamzad
General User
General User


Joined: 08 Mar 2011
Posts: 16
Location: Buena Park, CA, USA

PostPosted: Wed May 25, 2011 9:46 am    Post subject: Reply with quote

Try using the Interaction Handler and assemble your GET request URL ahead of time. The nice thing about the Interaction Handler is that it works the same for both HTTP and HTTPS... as long as the form uses the "GET" submission method (as yours appears to). Send your query request directly to the script via a complete URL. In the code listed in the second post of this thread, change this line:

Code:
  aURL = "https://dpinfo.dpma.de/index_e.html"

to something that matches your form data and action (similar to this):

Code:
  aURL = "https://www.googleapis.com/tasks/v1/lists/MDk5Nzc1MDY0NzQyMTk4NjEyMzM6MDow/tasks/MDk5Nzc1MDY0NzQyMTk4NjEyMzM6MDo4?pp=1&key={YOUR_API_KEY}"

It should take this basic form:

aURL = "https://FQDN.of.Server/Path/To/Script?Form_Field_Name1=Form_Field_Data1&Form_Field_Name2=Form_Field_Data2"

Hope this helps!
Adam-Zad, The Bear That Looks Like A Man
Back to top
View user's profile Send private message
Fernand
OOo Enthusiast
OOo Enthusiast


Joined: 22 Jun 2004
Posts: 142

PostPosted: Wed May 25, 2011 11:41 pm    Post subject: Reply with quote

Hey Beerman (man-bear) in dutch
thanks for your reply
but the interacttion handler seems not to work as expected.
please trye some code i made for using Google to translate in OO. Here we need only HTTP and i use the connector who works fine.
Trye this URL with the interaction handler...

Code:

sub GoogleTranslate
cCR = Chr(13)
cLF = Chr(10)
oConnector = createUnoService("com.sun.star.connection.Connector")
oConnection = oConnector.connect("socket,host=www.googleapis.com,port=80")
ToTranslate = "ik%20gelijk%20op%20 een%20beer"
sSourceLang = "nl"
sTargetLang = "en"
oConnection.write( StringToByteArray( "GET http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q="& sToTranslate & "&langpair=" & sSourceLang & "|" & sTargetlang  + cCR + cLF+ cCR +cLF ) )
oConnection.flush()
aByteArray  = Array()
nBytesRead = oConnection.read(aByteArray, 1000)
 oPipe    = createUNOService ("com.sun.star.io.Pipe") ' heeft zowel een In als OUtput stream
oTextInp = createUNOService ("com.sun.star.io.TextInputStream") 'kan lezen
oTextOut = createUNOService ("com.sun.star.io.TextOutputStream")' kan schrijven
oTextInp.setInputStream(opipe) 'maakt dat pipe kan lezen
otextOut.setOutputStream(opipe) 'maakt dat pipe kan schrijven
otextout.setencoding("ISO-8859-1")
otextOut.writestring(ByteArrayToString(aByteArray)) 'schrijft de string naar Pipe
s = oTextinp.readstring(Array("}"), true)
msgbox(s)
end sub
Function StringToByteArray( ByVal cString As String )
   nNumBytes = Len( cString )
   Dim aBytes(nNumBytes-1) As Integer
   For i = 1 To nNumBytes
      cChar = Mid( cString, i, 1 )
      nByte = Asc( cChar )
      nByte = IntegerToByte( nByte )
      aBytes(i-1) = nByte
   Next
   StringToByteArray() = aBytes()
End Function
Back to top
View user's profile Send private message Send e-mail
Fernand
OOo Enthusiast
OOo Enthusiast


Joined: 22 Jun 2004
Posts: 142

PostPosted: Thu May 26, 2011 2:10 am    Post subject: Reply with quote

Sorry,
It WORKS for my GoogleTransmations
stupid me forgot wrap the "GET" in the URL must be "http//ajax...." not "GET http//ajax..."

ok now trye to get the https at work and a LO developer showed me the path for use of POST also
Back to top
View user's profile Send private message Send e-mail
adamzad
General User
General User


Joined: 08 Mar 2011
Posts: 16
Location: Buena Park, CA, USA

PostPosted: Thu May 26, 2011 4:05 pm    Post subject: Reply with quote

Fernand,
Try this code, it works the same for HTTP and HTTPS with a simple change of the protocol identifier in the URL:

Code:
REM  *****  BASIC  *****

Global ms777_InteractionHandler as Any

Sub GoogleTranslate
'Declare and Initialize Variables:
  Dim sToTranslate as String : sToTranslate = "ik%20gelijk%20op%20 een%20beer"
  Dim sSourceLang as String : sSourceLang = "nl"
  Dim sTargetLang as String : sTargetLang = "en"
  Dim aURL as String
  aURL = "https://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=" & sToTranslate & "&langpair=" & sSourceLang & "|" & sTargetlang

  Dim Keys(1) as String
  Keys( 0 ) = "Local"
  Keys( 1 ) = "Office"
 
  oUCB = getProcessServiceManager().createInstanceWithArguments("com.sun.star.ucb.UniversalContentBroker", Keys )

  xId = oUCB.createContentIdentifier(aURL)
  xContent = oUCB.queryContent(xId)

'Create an Empty Command Environment:
  oCommandEnvironment = createUnoListener("XCE_", "com.sun.star.ucb.XCommandEnvironment")
  ms777_InteractionHandler = createUnoListener("XIH_", "com.sun.star.task.XInteractionHandler")

'Find out if it is really a document:
  Dim aProps(0) as new com.sun.star.beans.Property
  aProps(0).Name = "IsDocument"
  aProps(0).Handle = -1

  xValues = executeCommand(xContent, "getPropertyValues", aProps, oCommandEnvironment)
  iCol = xValues.FindColumn("IsDocument")
  bResult = xValues.GetBoolean(iCol)
  If NOT bResult Then
    MsgBox "No Document!"
    Exit Sub
  End If

'Create Temporary Storage:
  Dim oStorageFac as Object
  Dim oStorage as Object
  Dim oStream as Object
 
  oStorageFac = createUnoService("com.sun.star.embed.StorageFactory")
  oStorage    = oStorageFac.createInstance
  oStream     = oStorage.openStreamElement("WebReply", com.sun.star.embed.ElementModes.READWRITE)

 
'Now, Try to Open:
  Dim oOpenCommand as new com.sun.star.ucb.OpenCommandArgument2
  oOpenCommand.Mode = com.sun.star.ucb.OpenMode.DOCUMENT
  oOpenCommand.Sink = oStream

  ExecuteCommand(xContent, "open", oOpenCommand, oCommandEnvironment)


'Now, move returned page into a string variable.
  Dim oInputText as Object
  Dim sFileText as String
  Dim DummyArray(0) : DummyArray(0) = ""
 
  oInputText = createUNOService ("com.sun.star.io.TextInputStream")
  oInputText.setInputStream(oStream)
  oInputText.InputStream.Seek(0)
  sFileText = oInputText.readString(DummyArray(), FALSE)
  oInputText.InputStream.Flush
  oInputText.CloseInput
  XRay sFileText
End Sub

Function ExecuteCommand(xContent as com.sun.star.ucb.XContent, aCommandName as String, aArgument as Any, oCommandEnvironment as Any) as Any
  Dim aCommand as new com.sun.star.ucb.Command
  aCommand.Name = aCommandName
  aCommand.Handle = -1
  aCommand.Argument = aArgument
 
  ExecuteCommand = xContent.execute(aCommand, 0, oCommandEnvironment)
End Function


Function XCE_getInteractionHandler() as com.sun.star.task.XInteractionHandler
  XCE_getInteractionHandler =  ms777_InteractionHandler
End Function

Function XCE_getProgressHandler() as com.sun.star.ucb.XProgressHandler
End Function

Sub XIH_Handle(xRequest as com.sun.star.task.XInteractionRequest)
  oRequest = xRequest.Request

  strResponse = "Response from InteractionHandler:" & Chr(13)
  strMessage = ""
  strDiagnostic = ""
  Dim oCertificate as Any
'  MsgBox IsEmpty(oCertificate)
 
  On Error Resume Next
  strResponse = strResponse & "Message: " & oRequest.Message & Chr(13)
  strResponse = strResponse & "Diagnostic: " & oRequest.Diagnostic & Chr(13)
  oCertificate = oRequest.Certificate
  On Error Goto 0
  If IsEmpty(oCertificate) Then
    strResponse = strResponse & "Certificate: none" & Chr(13)
  Else
    strResponse = strResponse & "Certificate IssuerName:" & oCertificate.IssuerName & Chr(13)
  End If


  aContinuation = xRequest.Continuations
  lUBound = UBound(aContinuation)

  strResponse = strResponse & Chr(13) & "# of continuations:" & (lUBound+1) & ", will select last ..."
  MsgBox strResponse

  If lUBound = 1 Then
    aContinuation(1).select
  End If
 
  If lUBound = 0 Then
    aContinuation(0).select
    End If
End Sub

Changing this line:
Code:
aURL = "https://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=" & sToTranslate & "&langpair=" & sSourceLang & "|" & sTargetlang

to this line:
Code:
aURL = "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=" & sToTranslate & "&langpair=" & sSourceLang & "|" & sTargetlang

is all the modification you need to change the code for HTTP vs. HTTPS. You need the Interaction Handler to make it work with HTTPS, so I figured a more versatile script that can handle both with a small, simple change would be a better solution than two separate scripts to handle each situation.

I'm still working on getting the POST submission method to work. What was the path to use POST? I've been struggling with that one.

Fair day and be well,
Adam-Zad, The Bear That Looks Like A Man
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group