【问题标题】:Sending string using POST in Corona在 Corona 中使用 POST 发送字符串
【发布时间】:2014-10-31 06:11:22
【问题描述】:

我正在尝试使用 Corona SDK 中的 POST 请求将数据发送到 PHP。
这个数据非常简单,就是单行字符串。

Corona 文档中给出的示例涉及自定义标头,以及发送某种我不理解或不需要的编码数据。我尝试使用 Post 发送单个字符串,但它不起作用。我的代码是:

local widget = require("widget")
local url = 'examplewebsite'


local function networkListener(query)
    if ( query.isError ) then
        print( "Network error!", query.response )
    else
        print ( "RESPONSE: " .. query.response )
    end
end


local function query()
    local params = {"hey"}
    print("Sending Request to Server...")
    network.request(url,"POST",networkListener,params)
end

local request_button = widget.newButton
{
    label = "SQL Request",
    left = 60,
    top = 230,
    fontSize = 35,
    onRelease = query
}

【问题讨论】:

    标签: php android post lua coronasdk


    【解决方案1】:

    试试这个

    local function query()
        local params = {
            body = "message=hey"
        };
        print("Sending Request to Server...")
        network.request(url,"POST",networkListener, params)
    end
    

    在 PHP 方面你应该得到 ​​p>

    __POST["message"] == "hey"
    

    【讨论】:

      猜你喜欢
      • 2018-11-08
      • 1970-01-01
      • 1970-01-01
      • 2015-02-11
      • 2017-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多