Christian ,

Thanks for your valuable help.

After i succeeded to use the OO connection stuff to use Google Translations i was tempted to use the newest Google Tasks API too.

Using port 443  i get no respons at all ?
I left my API_Key out for security reasons.
But

In my working code for Translations i used
GET http://ajax.googleapis.com/....

so i am a bit confused about the syntax to make HHTP requests :-)

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") 'je%20suis%20au%20l'intérieur%20du%20magazin
sToTranslate = "voetbal"
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

Hi Fernand, *,

On Wed, May 25, 2011 at 9:24 AM, Fernand Vanrie<s...@pmgroup.be>  wrote:
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")
first: don't know whether it is  supported by OOo like this, but your
example has several general problems, so here we go...

If you want to use ssl, then you should try with the default ssl-port (443)

oConnection.write( StringToByteArray( "GET
https://www.googleapis.com/tasks/v1/lists/MDk5Nzc1MDY0NzQyMTk4NjEyMzM6MDow/tasks/MDk5Nzc1MDY0NzQyMTk4NjEyMzM6MDo4?pp=1&key=
And http GET doesn't include the hostname, just the path. Specify the
host in the Host parameter.

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

and you're not supposed to write it twice either, but maybe I'm
getting things wrong here.
And obviously "YOUR_API_KEY" is to be replaced by your API key.

it's
GET /path/to?param=value&param2=value2 HTTP/1.1
Host: www.myhost.com
Connection: close

(well, connection: close as it is the only request, you can also just
use http 1.0 request that only have one request at a time anyway)

ciao
Christian

--
-----------------------------------------------------------------
To unsubscribe send email to dev-unsubscr...@api.openoffice.org
For additional commands send email to sy...@api.openoffice.org
with Subject: help

Reply via email to