Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
UrlLoader.POST - Gideros Forum

UrlLoader.POST

zvardinzvardin Member
edited March 2013 in General questions
Ok, I've seen some old discussions on this, but I'm curious what I'm doing wrong. When using UrlLoader.POST I've only had success if on my server I check the HTTP_RAW_POST_DATA in PHP (in that instance I'm sending a json table so that's fine), but I've had no luck sending named variables to POST as discussed here: http://www.giderosmobile.com/forum/discussion/1508/post-and-get-methods

So if I send "name=Zvardin" for instance, there is no $_POST['name']. I'm wondering if @loves_oi had the same issue and thus decided to use GET in their instance. I can workaround it, but would really love to know what I'm missing.

Comments

  • ar2rsawseenar2rsawseen Maintainer
    edited March 2013 Accepted Answer
    This sounds similar to this:
    http://www.giderosmobile.com/forum/discussion/1966/http-request-to-scoreoid-server-using-url-loader.#Item_5

    You should add ["Content-Type"] = "application/x-www-form-urlencoded", to headers

    as
    local headers = {
    	["Content-Type"]  = "application/x-www-form-urlencoded"
    }
     
    local method = UrlLoader.POST
    local body = "name=Zvardin"
    local url = "<a href="http://www.urltosenf.com/&quot" target="_blank" rel="nofollow">http://www.urltosenf.com/&quot</a>;
    local loader = UrlLoader.new(url, method, headers, body)
     
    local function onComplete(event)
    	print(event.data)
    end
     
    loader:addEventListener(Event.COMPLETE, onComplete)
  • Awesome, I didn't see that thread! Maybe this could be included in the UrlLoader documentation for POST responses, since I imagine this would be somewhat common desired functionality. @ar2sawseen to the rescue again! ;)
Sign In or Register to comment.