Hi guys,
What is the recommended method for accessing web services in Lua/Corona?
Thanks,
Matt. [import]uid: 8271 topic_id: 6167 reply_id: 306167[/import]
Hi guys,
What is the recommended method for accessing web services in Lua/Corona?
Thanks,
Matt. [import]uid: 8271 topic_id: 6167 reply_id: 306167[/import]
+1 [import]uid: 31718 topic_id: 6167 reply_id: 22545[/import]
http://developer.anscamobile.com/content/network-0 [import]uid: 12108 topic_id: 6167 reply_id: 22560[/import]
I came across this http://keplerproject.github.com/lua-xmlrpc/manual.html#client this morning. I haven’t tried using it, but I also need to find a solution to calling web-services, so if anyone else has any ideas I would be grateful.
Joe [import]uid: 5963 topic_id: 6167 reply_id: 23665[/import]
Thanks, but I have to say I’ve had a lot of success since async http came into Corona and using the LuaXML API (http://lua-users.org/wiki/LuaXml) has made turning parsed XML into a table collection very nice indeed.
matt. [import]uid: 8271 topic_id: 6167 reply_id: 23681[/import]
Thanks for the response I hadn’t yet come across LuaXml, you’re right it seems like a good solution.
I am still collecting my thoughts on this, but have you had to transfer any files? Right now I am using the ftp implementation, but going forward I know I will be forced to use a web-service call that will expect a byte[]. Any thoughts on this?
Joe [import]uid: 5963 topic_id: 6167 reply_id: 23687[/import]
Sorry, no. I’ve just ensured that I get to submit XML blocks or GET requests so it’s all plain XML to me. [import]uid: 8271 topic_id: 6167 reply_id: 23697[/import]
Please post a sample code to consume soap web service using corona SDK. Thanks in advance.
Sri [import]uid: 91282 topic_id: 6167 reply_id: 56082[/import]
I was trying to send XML based soap web services request and expecting XML based soap response using async http came with Corona SDK. I also have to do basic authentication. How can send request with basic authentication credentials using async http with Carona sdk ?
Thanks in advance
Sri [import]uid: 91282 topic_id: 6167 reply_id: 56191[/import]
+1 [import]uid: 14336 topic_id: 6167 reply_id: 59773[/import]
Does anybode has an exmaple on how to post JSON data to a web service? [import]uid: 19590 topic_id: 6167 reply_id: 88328[/import]
http://developer.anscamobile.com/reference/index/networkrequest
In the third code snippet, set the value of params.body to your JSON content. [import]uid: 8271 topic_id: 6167 reply_id: 88332[/import]
I did that, but how do I handle the quotes of the json string?
Because now I’m posting this as body value:
body = "{Adress1:String content,Adress2:String content,City:String content,Country:String content,Id:String content,Name:String content,VATNumber:String content,Zip:String content}"
Already thank you for the reply [import]uid: 19590 topic_id: 6167 reply_id: 88334[/import]
Ah, not sure. [import]uid: 8271 topic_id: 6167 reply_id: 88336[/import]
Got it working, I forgot to use the JSON functions.
regards,
Jürgen
local jsonData = json.encode (t)
where t is my table with data to encode as json
[import]uid: 19590 topic_id: 6167 reply_id: 88370[/import]
@jpenne
could you please post a sample of your code?
Thanks,
RD [import]uid: 7856 topic_id: 6167 reply_id: 88538[/import]
Well this was a login system I setup in PHP on my webserver. It connects with my database. Since you want to see the web service side of it, I won’t go into the PHP/mySQL bits, just the Corona bits:
local json = require("json")
function login(username, password, callback)
print("login")
network.request( "http://mysite.com/api/login.php?playername=" .. mime.b64(username) .. "&password=" .. mime.b64(password), "GET", callback )
end
local function loginCallBack(event)
if ( event.isError ) then
print( "Network error!")
else
print ( "RESPONSE: " .. event.response )
local data = json.decode(event.response)
print\_r(data)
end
return true
end
-- make the call
login(user, pass, loginCallBack)
Basically you make an HTTP GET (PUT, POST or DELETE) request using the network.request API. When it completes, a call back function executes that lets you then deal with the data.
Whatever the server returns is a string in the event.response table entry. I’m expecting JSON data in my case, so I just do a json.decode on event.response and end up with a lovely table to work with.
If you’re expecting XML, event.response will have the XML and on the Corona Blog a few months ago, they blogged about parsing XML. Read that post, and use it to unpack event.response and away you go.
[import]uid: 19626 topic_id: 6167 reply_id: 88544[/import]
Hi robmiracle,
I am trying to find out how to connect with instagram api. Do you have any suggestions how to do that. With some simple login sempla maybe,
Best Regards
[import]uid: 8303 topic_id: 6167 reply_id: 112788[/import]
I have never looked at Instagram’s API. I’m a professional photographer and I have no desire to step on their bandwagon.
They probably use oAUTH to log in and you and repurpose the oAUTH.lua file from the twitter sample project to get you logged in. Then I suspect the rest is probably just HTTP GET and PUT calls with the right parameters.
[import]uid: 19626 topic_id: 6167 reply_id: 112807[/import]
Hi Bogdan,
The API used to have good examples - I’m pretty sure the sample code which comes with the SDK does. If you look up how to make a POST request you would be well on the way. Calling any XML service will be pretty much the same. Give it a go and if it doesn’t pan out post here again with the code you have and I’ll take a look. The tricky part is probably getting the order correct for which web methods you need to call on the service and the proper values to send. That is all up to your developer account which usually are free to setup but need an access token or auth key, which is just a string unique to your dev account.
Matt. [import]uid: 8271 topic_id: 6167 reply_id: 112813[/import]