Http POST request not working on mobile

Hello everyone.

I’m trying to send a variable from my Android to a php page using the Asynchronous HTTP sevice but I have no result. The application does very well in the simulator, but fails on the device. I have internet service enabled or so it seems, also comes by default when you create a new application in Corona. Any help is very welcome. It is assumed that should be something easy. Maybe I’m missing some detail.

Thanks.

How you do the http request ? I was using this code without any problem:

Request:

local sendInfo = {                     ["var1"] = urlEncode(valueForVar1),                      ["var2"] = urlEncode(valueForVar2)                 }              local params = {}             params.body = json.encode( sendInfo )             local headers = {                     ["Content-Type"] = "application/json",                     ["Accept-Language"] = "en-US",                     ["Content-Length"] = #params.body             }                          params.headers = headers             network.request( "http://www.yourserver.com/yourphppage.php", "POST", networkRequestListener, params)

Response listener:

function networkRequestListener( event )     if ( event.isError ) then         native.setActivityIndicator(false)    else         native.setActivityIndicator(false)         print\_r(event.response)         local decodedResponse = json.decode(event.response)    end end

Hope this can help you…

Thanks for the reply. I found that the problem lies elsewhere in the system. Im trying to acces localhost. I have to go to back to see what happens. Thanks for you interest anyway.

How you do the http request ? I was using this code without any problem:

Request:

local sendInfo = {                     ["var1"] = urlEncode(valueForVar1),                      ["var2"] = urlEncode(valueForVar2)                 }              local params = {}             params.body = json.encode( sendInfo )             local headers = {                     ["Content-Type"] = "application/json",                     ["Accept-Language"] = "en-US",                     ["Content-Length"] = #params.body             }                          params.headers = headers             network.request( "http://www.yourserver.com/yourphppage.php", "POST", networkRequestListener, params)

Response listener:

function networkRequestListener( event )     if ( event.isError ) then         native.setActivityIndicator(false)    else         native.setActivityIndicator(false)         print\_r(event.response)         local decodedResponse = json.decode(event.response)    end end

Hope this can help you…

Thanks for the reply. I found that the problem lies elsewhere in the system. Im trying to acces localhost. I have to go to back to see what happens. Thanks for you interest anyway.