我正在尝试使用以下代码发送 JSON 请求以发送推送通知,但我收到网络响应的错误消息,提示“未找到 app_id”。我正在使用 Corona,但只要 JSON 格式正确,这并不重要。
local json = require "json"
local function networkListener( event )
if ( event.isError ) then
print( "Network error!" )
else
print ( "RESPONSE: " .. event.response )
end
end
headers = {}
headers["app_id"] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
headers["Authorization"] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
headers["Content-Type"] = "application/json"
local params = {}
commands_json =
{
["contents"] = "English Message"
}
postData = json.encode(commands_json)
local params = {}
params.header = headers
params.body = postData
network.request( "https://onesignal.com/api/v1/notifications","POST",networkListener,params)