lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Leo wrote:
> After some googling I still cannot find any code that would allow me
> to search Google from within Lua scripts using Google SOAP API. I can
> do it with ease in Ruby or Python but not in Lua. Weird:-)

SOAP is a bit of a PITA.

But here is what I did a little while back using luasoap-1.0b:

> require "soap.http"
> ns, meth, ent = soap.http.call("http://api.google.com/search/beta2";, "urn:GoogleSearch", "doGoogleSearch",
>>	{ { tag = "key", attr = { ["xsi:type"] = "xsd:string" }, "<your Google auth key>" },
>>	{ tag = "q", attr = { ["xsi:type"] = "xsd:string" }, "luasoap" },
>>	{ tag = "start", attr = { ["xsi:type"] = "xsd:int" }, 0},
>>	{ tag = "maxResults", attr = { ["xsi:type"] = "xsd:int" }, 10},
>>	{ tag = "filter", attr = { ["xsi:type"] = "xsd:boolean" }, true},
>>	{ tag = "restrict", attr = { ["xsi:type"] = "xsd:string" }, ""},
>>	{ tag = "safeSearch", attr = { ["xsi:type"] = "xsd:boolean" }, true},
>>	{ tag = "lr", attr = { ["xsi:type"] = "xsd:string" }, ""},
>>	{ tag = "ie", attr = { ["xsi:type"] = "xsd:string" }, ""},
>>	{ tag = "oe", attr = { ["xsi:type"] = "xsd:string" }, ""} } )
> for k, v in pairs(ent[2][12][2][2]) do print(k, v) end
attr    table: 0045A4C8
1       http://www.keplerproject.org/luasoap/
tag     URL
>

Essentially, the result of the SOAP request is a LOM tree, that you'll
have to decode yourself.  Not hard, just tedious.

Anyone out there working on a WSDL to Lua stub generator?

Robby