Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
interacting with a website from gideros app — Gideros Forum

interacting with a website from gideros app

piepie Member
edited July 2017 in General questions
Hi I am planning to put together a website (maybe using a cms) and a gideros app to let registered users update some info on it.
I saw some old post about REST api but it seems that the app needs to open a browser window to interact with the website.
How would you do it? Is there something "better" than REST,which can be used without opening a browser window on the device?
Any other suggestions?

Thank you

Comments

  • talistalis Guru
    Accepted Answer
    It seems , urlloader is your answer.
    See this post for detail;
    http://giderosmobile.com/forum/discussion/1508/post-and-get-methods/p1

    Likes: hgy29, antix, pie, totebo

    +1 -1 (+4 / -0 )Share on Facebook
  • piepie Member
    edited September 2017
    UrlLoader is my answer! thank you :)
    however I have some strange behaviours using it - which could be related.

    1) I can't access my php page using https (which should be supported as said in documentation)

    but as I said, this may be coming from:

    2) If I write the same url by hand and concatenate strings to get it, I have different results: the first works, the latter returns an error from php.

    I made a string comparison using string.byte on each char of the strings, and I found out that even if the strings look the same, they have different bytecodes: moreover, if I print out the characters while I am comparing them - they don't look the same! :-O
    But they look the same in gideros Output panel if I print the concatenated strings..

    This is what I got: here you can find the mismatching characters in my url, I don't know if there are others:

    "source_ok" is the character as it should be (written "by hand")
    "parsed_bad" is the character as it comes out from string concatenation from gideros (it was originally inserted by hand - so it should be the same as source, but then it is concatenated with others and it "changes"?)
    "badchar" is the string.sub(parsedString, i,i)
    "okchar" is the string.sub(sourceString, i,i)
    [{"source_ok":115,"parsed_bad":97,"badchar":"a","okchar":"s"},{"source_ok":97,"parsed_bad":115,"badchar":"s","okchar":"a"},{"source_ok":101,"parsed_bad":108,"badchar":"l","okchar":"e"},{"source_ok":118,"parsed_bad":111,"badchar":"o","okchar":"v"},{"source_ok":101,"parsed_bad":99,"badchar":"c","okchar":"e"},{"source_ok":110,"parsed_bad":97,"badchar":"a","okchar":"n"},{"source_ok":115,"parsed_bad":105,"badchar":"i","okchar":"s"},{"source_ok":61,"parsed_bad":111,"badchar":"o","okchar":"="},{"source_ok":98,"parsed_bad":110,"badchar":"n","okchar":"b"},{"source_ok":115,"parsed_bad":95,"badchar":"_","okchar":"s"},{"source_ok":97,"parsed_bad":105,"badchar":"i","okchar":"a"},{"source_ok":112,"parsed_bad":100,"badchar":"d","okchar":"p"},{"source_ok":112,"parsed_bad":61,"badchar":"=","okchar":"p"},{"source_ok":95,"parsed_bad":49,"badchar":"1","okchar":"_"},{"source_ok":101,"parsed_bad":38,"badchar":"&","okchar":"e"},{"source_ok":118,"parsed_bad":100,"badchar":"d","okchar":"v"},{"source_ok":101,"parsed_bad":97,"badchar":"a","okchar":"e"},{"source_ok":110,"parsed_bad":121,"badchar":"y","okchar":"n"},{"source_ok":116,"parsed_bad":115,"badchar":"s","okchar":"t"},{"source_ok":105,"parsed_bad":61,"badchar":"=","okchar":"i"},{"source_ok":95,"parsed_bad":49,"badchar":"1","okchar":"_"},{"source_ok":115,"parsed_bad":48,"badchar":"0","okchar":"s"},{"source_ok":101,"parsed_bad":38,"badchar":"&","okchar":"e"},{"source_ok":114,"parsed_bad":101,"badchar":"e","okchar":"r"},{"source_ok":105,"parsed_bad":118,"badchar":"v","okchar":"i"},{"source_ok":97,"parsed_bad":110,"badchar":"n","okchar":"a"},{"source_ok":38,"parsed_bad":116,"badchar":"t","okchar":"&"},{"source_ok":108,"parsed_bad":115,"badchar":"s","okchar":"l"},{"source_ok":111,"parsed_bad":61,"badchar":"=","okchar":"o"},{"source_ok":99,"parsed_bad":98,"badchar":"b","okchar":"c"},{"source_ok":97,"parsed_bad":115,"badchar":"s","okchar":"a"},{"source_ok":116,"parsed_bad":97,"badchar":"a","okchar":"t"},{"source_ok":105,"parsed_bad":112,"badchar":"p","okchar":"i"},{"source_ok":111,"parsed_bad":112,"badchar":"p","okchar":"o"},{"source_ok":110,"parsed_bad":95,"badchar":"_","okchar":"n"},{"source_ok":95,"parsed_bad":101,"badchar":"e","okchar":"_"},{"source_ok":105,"parsed_bad":118,"badchar":"v","okchar":"i"},{"source_ok":100,"parsed_bad":101,"badchar":"e","okchar":"d"},{"source_ok":61,"parsed_bad":110,"badchar":"n","okchar":"="},{"source_ok":49,"parsed_bad":116,"badchar":"t","okchar":"1"},{"source_ok":38,"parsed_bad":105,"badchar":"i","okchar":"&"},{"source_ok":100,"parsed_bad":95,"badchar":"_","okchar":"d"},{"source_ok":97,"parsed_bad":115,"badchar":"s","okchar":"a"},{"source_ok":121,"parsed_bad":101,"badchar":"e","okchar":"y"},{"source_ok":115,"parsed_bad":114,"badchar":"r","okchar":"s"},{"source_ok":61,"parsed_bad":105,"badchar":"i","okchar":"="},{"source_ok":49,"parsed_bad":101,"badchar":"e","okchar":"1"},{"source_ok":48,"parsed_bad":97,"badchar":"a","okchar":"0"}]
    This is the snippet that generated the table above
    local compare = {}
     
    local tva = {}
    local urlva = handwrittenUrl
    for i=1, #urlva do
    	local s = string.byte(urlva,i)
    	tva[#tva+1] = s
     
    end
     
    local tnonva = {}
    local urlnonva = parsedUrl
    for i=1, #urlnonva do
    	local s = string.byte(urlnonva,i)
    	tnonva[#tnonva+1] = s
     
    end
     
    if #tva == #tnonva then
    	for i=1, #tva do 
     
     
    	if tva[i] == tnonva[i] then
     
    		else
    			print("MISMATCH:", i, "tva: "..tva[i], "tnonva: "..tnonva[i])
    			compare[#compare+1] = {source_ok = tva[i], parsed_bad = tnonva[i], okchar = string.sub(urlva, i, i), badchar = string.sub(urlnonva, i, i)}
    		end
    	end
     
     
    else
    	print("error, string lenght is different")
    end
    I could give you the test urls and more details via email/pm: I don't like to share my test server details on the public internet ;)

    @n1cke could this be related to the latest bug you fixed in layout (http://giderosmobile.com/forum/discussion/comment/52790#Comment_52790 ) ?

    Any help is appreciated, thank you :)
  • hgy29hgy29 Maintainer
    Accepted Answer
    @pie, gideros console interprets HTML, so if you try to print out html encoded strings, they will be shown unencoded.

    Also for SSL, if it doesn't work on player it means that you lack a specific DLL, which isn't provided by QT nor gideros due to potential licensing issues. There is a bug report about this in gideros github...
  • SinisterSoftSinisterSoft Maintainer
    Accepted Answer
    Here are the extra files for ssl (windows players) - just unrar into the gideros folder in program files:

    https://www.dropbox.com/s/y8ixf3d03ygf29t/extra_ssl.rar?dl=0
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • piepie Member
    edited September 2017
    Thank you! :)
    for the records the issue is this one: I forgot about that
    https://github.com/gideros/gideros/issues/50

    Now my question is: should it work out of the box on android player or there is something else to do?
    The same app that works with @Sinistersoft files on windows player, on Android player gets an error (not better defined) as response.

    If I set
    UrlLoader:ignoreSslErrors()

    I can see that my output is error 403 Forbidden
    Thank you

    p.s. if I use plain http it works, but I'd like to use https ;)
  • hgy29hgy29 Maintainer
    If you get a 403 response then it means that SSL handshake did succeed, and the server itself forbids you the access to the URL you asked. It can happen when the server does name based virtual hosting but the ssl stack doesn't support SNI extension.
  • Thank you, I will check with my hosting provider. But if the problem is this one shouldn't it happen on windows player too?
  • hgy29hgy29 Maintainer
    Accepted Answer
    Not necessariy, Gideros uses the OS routines to open http connections. It is possible that windows libs do support SNI while Android do not.
    In the case of Android, we are using the (deprecated) Apache HTTP library, which, according to this site: https://stackoverflow.com/questions/5879894/android-ssl-sni-support doesn't support SNI. The best way forward would be to switch to the official android HTTP library...

    Likes: antix, pie

    +1 -1 (+2 / -0 )Share on Facebook
  • piepie Member
    edited October 2017
    I need to use https with urlloader:
    while gideros uses apache http library, as a workaround, is there a way to know if a host would work with gideros urlloader https before buying it? What should I ask to the hosting support?

    Thank you :)
Sign In or Register to comment.